D
deko
I just upgraded to Office 2007 and would like to refactor my automation code
to improve speed and perhaps add some new functionality.
My Access 2007 database has code that searches Outlook 2007 for email
messages. The database contains Contacts, each with one or more email
addresses. The current code loops through each message in the Outlook Inbox
trying to match one of the Contact's email addresses with the
SenderEmailAddress property of each mail item. When a match is found, the
message subject and other data is added to a recordset and displayed in a
datasheet in Access.
Here's an abbreviated example:
Dim olapp As Outlook.Application
Dim olmi as Outlook.MailItem
Dim olitms as Outlook.Items
Dim objItem As Object
Set olapp = New Outlook.Application
Set olns = olapp.GetNamespace("MAPI")
Set olFolder = olns.GetDefaultFolder(olFolderInbox)
Set olitms = olFolder.Items
Do While Not rstContactAddresses.EOF
For Each objItem in olitms
If TypeOf objItem Is Outlook.MailItem Then
Set olmi = objItem
If olmi.SenderAddress = rstContactAddresses!EmailAddress Then
Call AddToRecordset(olmi.whatever)
End if
End if
Next objItem
Loop
Is there a better way to do this with VBA? Is it worth trying to use C# and
VSTO here? Is it possible to tap into the indexed Outlook email search
feature? Other new stuff in 2007 that can help?
Thanks in advance.
to improve speed and perhaps add some new functionality.
My Access 2007 database has code that searches Outlook 2007 for email
messages. The database contains Contacts, each with one or more email
addresses. The current code loops through each message in the Outlook Inbox
trying to match one of the Contact's email addresses with the
SenderEmailAddress property of each mail item. When a match is found, the
message subject and other data is added to a recordset and displayed in a
datasheet in Access.
Here's an abbreviated example:
Dim olapp As Outlook.Application
Dim olmi as Outlook.MailItem
Dim olitms as Outlook.Items
Dim objItem As Object
Set olapp = New Outlook.Application
Set olns = olapp.GetNamespace("MAPI")
Set olFolder = olns.GetDefaultFolder(olFolderInbox)
Set olitms = olFolder.Items
Do While Not rstContactAddresses.EOF
For Each objItem in olitms
If TypeOf objItem Is Outlook.MailItem Then
Set olmi = objItem
If olmi.SenderAddress = rstContactAddresses!EmailAddress Then
Call AddToRecordset(olmi.whatever)
End if
End if
Next objItem
Loop
Is there a better way to do this with VBA? Is it worth trying to use C# and
VSTO here? Is it possible to tap into the indexed Outlook email search
feature? Other new stuff in 2007 that can help?
Thanks in advance.