Import the body of an Email into Access (1 Viewer)

CBO

Registered User.
Local time
Today, 18:41
Joined
Aug 8, 2005
Messages
10
I'm having a terrible importing the body of an Outlook message into Microsoft Access. :confused:

Anyone know of an easy way to do this, or has some code that can do this for me.

Thanks
CBO
 

bonekrusher

Registered User.
Local time
Today, 15:41
Joined
Nov 19, 2005
Messages
266
Make sure MS Outlook is selected in the reference library

Code:
Private Sub Command0_Click()
' Open outlook and select a folder, create a form with a button called command0 and a text field called text1 
Dim objApp As Outlook.Application
    Dim objItem As Outlook.MailItem
    Dim SndName As String, SndAddr As String, ToName As String, CCName As String
    Dim Subj As String, Rcvd As String, MsgBody As String, AtchName As String
    Set objApp = New Outlook.Application
    For Each objItem In objApp.ActiveExplorer.Selection
        If objItem.Class = olMail Then
            With objItem
                SndName = .SenderName
                SndAddr = .SenderEmailAddress
                ToName = .To
                CCName = .CC
                Subj = .Subject
                MsgBody = .Body
                Rcvd = .ReceivedTime
            
            End With
        End If
    Next
   
Me.Text1 = MsgBody
 Set objItem = Nothing
    Set objApp = Nothing
End Sub
 

ttamilvanan81

New member
Local time
Tomorrow, 04:11
Joined
Mar 30, 2007
Messages
6
Problem for using ur Coding for Receive Email using Access

Make sure MS Outlook is selected in the reference library

Code:
Private Sub Command0_Click()
' Open outlook and select a folder, create a form with a button called command0 and a text field called text1 
Dim objApp As Outlook.Application
    Dim objItem As Outlook.MailItem
    Dim SndName As String, SndAddr As String, ToName As String, CCName As String
    Dim Subj As String, Rcvd As String, MsgBody As String, AtchName As String
    Set objApp = New Outlook.Application
    For Each objItem In objApp.ActiveExplorer.Selection
        If objItem.Class = olMail Then
            With objItem
                SndName = .SenderName
                SndAddr = .SenderEmailAddress
                ToName = .To
                CCName = .CC
                Subj = .Subject
                MsgBody = .Body
                Rcvd = .ReceivedTime
            
            End With
        End If
    Next
   
Me.Text1 = MsgBody
 Set objItem = Nothing
    Set objApp = Nothing
End Sub


Hai. i need to Receive Email using Access. Am searching with this Forum and i got ur Coding.
Thanks alot!
But while run this code error could be occured at the following line
For Each objItem In objApp.ActiveExplorer.Selection

The Error Message was:

Run-time error 91:

Object variable or With block variable not set


I don't know why this error was occured, If you know Please intimate me.

Thanks
Tamilvanan
 

Users who are viewing this thread

Top Bottom