Hi
I used the code below in Access 2002 to save an Outlook e-mail and any attachments to a specified folder. I recently upgraded to Access 2010 and have found that the part of the code that saves the attachments (in bold below) no longer works. I get an error message Compile error: Method or data member not found. If I "rem" out that part of the code, the e-mail itself saves OK.
Any advice would be greatly appreciated.
Thanks
AL
I used the code below in Access 2002 to save an Outlook e-mail and any attachments to a specified folder. I recently upgraded to Access 2010 and have found that the part of the code that saves the attachments (in bold below) no longer works. I get an error message Compile error: Method or data member not found. If I "rem" out that part of the code, the e-mail itself saves OK.
Any advice would be greatly appreciated.
Thanks
AL
Code:
If Me.docfolder = "" Then GoTo nofolder
Dim ol As Outlook.Application
Dim ns As Namespace
Dim folder As MAPIFolder
Dim i As Integer
Dim email As MailItem
Dim emailsubject As String
Dim emailname As String
Dim email1 As MailItem
Dim att As Attachment
Set ol = CreateObject("outlook.application")
Set ns = ol.GetNamespace("MAPI")
ns.Logon
Set folder = ns.GetDefaultFolder(olFolderInbox)
Set email = folder.Items.GetLast
Me.tbl_Correspondence_subform2.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.tbl_Correspondence_subform2!Date = email.ReceivedTime
emailname = Forms!Form1!docfolder & "\Email " & Me.tbl_Correspondence_subform2!ID & ".msg"
email.SaveAs emailname, olMSG
Me.tbl_Correspondence_subform2!Details = "From: " & email.SenderName & " - " & email.Subject
Me.tbl_Correspondence_subform2!Link = "Email#" & emailname & "#"
[b]For Each att In email.Attachments
att.SaveAsFile Forms!Form1!docfolder & "\" & att.FileName
Next att[/b]
Exit Sub
nofolder:
MsgBox "Document folder has not been specified.", vbInformation, "Cannot continue"
Me.Document_folder.SetFocus
End Sub