Hi,
I want to import Outlook messages, including the header, into Access.
Accessing most fields is straightforward but I'm having problems
mapping the to/recipient field. When I use something like 'rst!To =
oMessage.Recipients' I get a 450 error message 'wrong number of
arguments or invalid property assignment.
I'm sure that the answer is staring me in the face but I can't see
it. Any help would be appreciated. I set out my code below.
Thanks in advance for any help.
Regards
Emmett
##################Code#################
Private Sub LoadEmails()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblEmails")
Dim oSession As MAPI.Session
Dim oFolder As Folder
Dim oMsgColl As Messages
Dim oMessage As Message
Dim c As Outlook.MailItem
' Logon to the MAPI session
Set oSession = New MAPI.Session
oSession.Logon
' Get the Inbox folder and its message collection.
Set oFolder =
oSession.GetDefaultFolder(CdoDefaultFolderInbox).Folders("Emails").Folders("ToImport")
Set oMsgColl = oFolder.Messages
For Each oMessage In oMsgColl
rst.AddNew
rst!Subject = oMessage.Subject
rst!Sender = oMessage.Sender
rst!Body = oMessage.Text
---------> rst!To = oMessage.Recipients <--------------------------
rst!ReceivedTime = oMessage.TimeReceived
rst!Header = oMessage.Fields(&H7D001E)
rst.Update
Next
' Logoff and cleanup
oSession.Logoff
Set oSession = Nothing
Set oMessage = Nothing
Set oMsgColl = Nothing
Set oFolder = Nothing
End Sub
Archived from group: microsoft>public>exchange>applications