J
jdpeterson
Hello,
The code below works pefectly on my own inbox, but dies on Pubic Folders.
VBA says the Mailobject does not support the "To" property, but only when I
access mail in Public Folders.
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim olapp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object 'Outlook.MailItem 'Object
Dim db As DAO.Database
Dim dealer As Integer
DoCmd.RunSQL "Delete * from EMail_temp"
Set db = CurrentDb
Set olapp = CreateObject("Outlook.Application")
Set Inbox = olapp.GetNamespace("MAPI").PickFolder
Set TempRst = CurrentDb.OpenRecordset("EMail_temp")
Set InboxItems = Inbox.Items
Inbox.Display
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
With TempRst
.AddNew
!Subject = Mailobject.Subject
!From = Mailobject.SenderName
!Body = Mailobject.Body
!Received = Mailobject.SentOn
!To = Mailobject.To
.Update
Mailobject.UnRead = False
End With
End If
Next
MsgBox "Done"
Set olapp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing
The code below works pefectly on my own inbox, but dies on Pubic Folders.
VBA says the Mailobject does not support the "To" property, but only when I
access mail in Public Folders.
Dim TempRst As DAO.Recordset
Dim rst As DAO.Recordset
Dim olapp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object 'Outlook.MailItem 'Object
Dim db As DAO.Database
Dim dealer As Integer
DoCmd.RunSQL "Delete * from EMail_temp"
Set db = CurrentDb
Set olapp = CreateObject("Outlook.Application")
Set Inbox = olapp.GetNamespace("MAPI").PickFolder
Set TempRst = CurrentDb.OpenRecordset("EMail_temp")
Set InboxItems = Inbox.Items
Inbox.Display
For Each Mailobject In InboxItems
If Mailobject.UnRead Then
With TempRst
.AddNew
!Subject = Mailobject.Subject
!From = Mailobject.SenderName
!Body = Mailobject.Body
!Received = Mailobject.SentOn
!To = Mailobject.To
.Update
Mailobject.UnRead = False
End With
End If
Next
MsgBox "Done"
Set olapp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
Set TempRst = Nothing