Opening and Extracting Data from Outlook Messages 
Author Message
 Opening and Extracting Data from Outlook Messages

I need to be able to get Access to look into a specified Outlook mailbox,
check if any messages exist, if so open each message in turn & extract the
info (the emails will be structured output from a web submit) and finally
export the analysed messages to an archive Outlook folder.

Any ideas of where to begin or useful sources of info?



Thu, 03 Apr 2003 12:27:08 GMT  
 Opening and Extracting Data from Outlook Messages


Quote:

>http://www.cdolive.com

>On Sun, 15 Oct 2000 05:27:08 +0100, "Mark C. Squire"

>>I need to be able to get Access to look into a specified Outlook
>>mailbox, check if any messages exist, if so open each message in
>>turn & extract the info (the emails will be structured output
>>from a web submit) and finally export the analysed messages to an
>>archive Outlook folder. Any ideas of where to begin or useful
>>sources of info?

http://www.ulster.net/~hfeddema/CodeSamples.htm


Thu, 03 Apr 2003 03:00:00 GMT  
 Opening and Extracting Data from Outlook Messages
Here is the bones of the code I wrote to do something very similar, but
it should be more than enough to get you started.
The code imports messages from a folder named 'Pending' under the
inbox.  I wrote code to move e-mails to that folder before importing in
case new e-mails arrived during the detail import process.  When the
data is imported I then move the items from the pending folder to
another folder to make sure that those details aren't imported again
next time the process runs.

You need to set a reference to the cdo library to get this get access
to the mapi properties and methods.

Sub GetFolderContents()
Dim mobjSession As MAPI.Session
Dim mobjFolder As Folder
Dim ShareFolder As MAPIFolder
Dim mobjMsgColl As Messages
Dim mobjMessage As Message
Dim objNameSpace As NameSpace
Dim dbEmail As database
Dim rsEmail As Recordset
Dim strMailbox As String
Dim txtSender As String
Dim txtSubject As String
Dim txtTimeReceived As String
Dim i As Integer
On Error GoTo ErrTrap
strMailbox = Me.txtMailbox ' A textbox holding the mailbox name
Set mobjSession = CreateObject("MAPI.Session")
mobjSession.Logon "---"
Set mobjFolder = mobjSession.GetDefaultFolder
(CdoDefaultFolderInbox).Folders("Pending")
Set dbEmail = CurrentDb
Set rsEmail = dbEmail.OpenRecordset("tblNewMessage", dbOpenDynaset)
Set mobjMsgColl = mobjFolder.Messages
i = 1
If Not 0 = mobjMsgColl.Count Then
    Set mobjMessage = mobjMsgColl.GetFirst()
    Do While Not mobjMessage Is Nothing
        With rsEmail
         .AddNew
         !Sender = mobjMessage.Sender.Name
         txtSender = mobjMessage.Sender.Name
         !MessageBody = mobjMessage.Text
         !SenderEmailAddress = mobjMessage.Sender.Address
         !TimeReceived = mobjMessage.TimeReceived
         txtTimeReceived = mobjMessage.TimeReceived
         !Subject = mobjMessage.Subject
         txtSubject = mobjMessage.Subject
         .Update
         Set mobjMessage = mobjMsgColl.GetNext
        End With
        i = i + 1
    Loop
strMsgResult = strMsgResult & "Messages were imported successfully." &
vbCrLf
Else
strMsgResult = strMsgResult & "There were no new messages." & vbCrLf
End If
Done:
Set rsEmail = Nothing
Set dbEmail = Nothing
Set mobjFolder = Nothing
Set mobjSession = Nothing
Exit Sub
ErrTrap:
If Err.Number = -2147221233 Then

Please check that you have a folder named 'Pending' " _

    , vbExclamation, "E-Mail Tracking"
Else

Some details may be missing from this enquiry."
    Resume Next
End If
GoTo Done
End Sub

Sent via Deja.com http://www.deja.com/
Before you buy.



Fri, 04 Apr 2003 03:00:00 GMT  
 Opening and Extracting Data from Outlook Messages
Many thanks to all who have posted advice and links.  Very grateful indeed.

Mark C. Squire



Sun, 06 Apr 2003 14:38:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Extract outlook messages w/ attachments to load to Access DB

2. Need a program to extract email addresses from MS Outlook 2000 folders/messages

3. Needed: Program to extract outlook messages

4. Extracting Exchange/Outlook info using Active Messaging 1.1 Object Library

5. Extract cell contents and import into an automated Outlook email message

6. Extracting certain data from messages in different folders.

7. extracting all the data from a Outlook calendar for all the users

8. Extracting data from embedded XML tags in Outlook e-mails

9. Extracting data from Outlook

10. extract data from outlook

11. Extract data from an Outlook PST file?

12. Opening Excel from Word and extracting data

 

 
Powered by phpBB® Forum Software