Hi there i have several queries designed to access outlook and pull through various information. the problem i have is that if there is a read receipt or meeting request, the query then fails.
The code i use is below. is there some script i could add to stop the error message appearing but also so that it still reads the rest of the mailbox.
Function Check_Emails174()
Dim rst As DAO.Recordset, tbl As TableDef, dbs As Database, tblname As String
Set dbs = CurrentDb
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim cf2 As Outlook.MAPIFolder
Dim C As Object
Dim objItems As Object
Dim Prop As Outlook.UserProperty
Dim I As Integer
Set rst = CurrentDb.OpenRecordset("report_26", dbOpenDynaset)
Set olns = ol.GetNamespace("MAPI")
Set cf2 = olns.Folders("Mailbox - mymailbox.com")
Set cf = olns.Folders("Mailbox - mymailbox.com").Folders("Inbox")
Set objItems = cf.Items
For I = 1 To objItems.Count
Set C = objItems(I)
rst.AddNew
If C.Subject <> "" Then
rst!Subject = C.Subject
Else
rst!Subject = " "
End If
If C.SentOn & "" <> """" Then
rst![Sent on] = C.SentOn
Else
rst![Sent on] = " "
End If
If C.SenderName <> "" Then
rst![From] = C.SenderName
Else
rst![From] = " "
End If
If C.To <> "" Then
rst![Sent To] = C.To
Else
rst![Sent To] = " "
End If
rst![Case] = C.UserProperties("Case")
rst![mailbox] = cf2.Name
rst![Reason] = C.UserProperties("Reason")
rst![mailbox] = cf2.Name
rst![LAST CONTACT] = C.UserProperties("Last Contact")
rst![mailbox] = cf2.Name
rst![Control] = C.UserProperties("Control")
rst![mailbox] = cf2.Name
rst![Description] = C.UserProperties("Description")
rst![mailbox] = cf2.Name
rst![Update] = C.UserProperties("Update")
rst![mailbox] = cf2.Name
rst![Dealing] = C.UserProperties("Dealing")
rst![mailbox] = cf2.Name
rst.Update
Next I
End Function
The code i use is below. is there some script i could add to stop the error message appearing but also so that it still reads the rest of the mailbox.
Function Check_Emails174()
Dim rst As DAO.Recordset, tbl As TableDef, dbs As Database, tblname As String
Set dbs = CurrentDb
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim cf2 As Outlook.MAPIFolder
Dim C As Object
Dim objItems As Object
Dim Prop As Outlook.UserProperty
Dim I As Integer
Set rst = CurrentDb.OpenRecordset("report_26", dbOpenDynaset)
Set olns = ol.GetNamespace("MAPI")
Set cf2 = olns.Folders("Mailbox - mymailbox.com")
Set cf = olns.Folders("Mailbox - mymailbox.com").Folders("Inbox")
Set objItems = cf.Items
For I = 1 To objItems.Count
Set C = objItems(I)
rst.AddNew
If C.Subject <> "" Then
rst!Subject = C.Subject
Else
rst!Subject = " "
End If
If C.SentOn & "" <> """" Then
rst![Sent on] = C.SentOn
Else
rst![Sent on] = " "
End If
If C.SenderName <> "" Then
rst![From] = C.SenderName
Else
rst![From] = " "
End If
If C.To <> "" Then
rst![Sent To] = C.To
Else
rst![Sent To] = " "
End If
rst![Case] = C.UserProperties("Case")
rst![mailbox] = cf2.Name
rst![Reason] = C.UserProperties("Reason")
rst![mailbox] = cf2.Name
rst![LAST CONTACT] = C.UserProperties("Last Contact")
rst![mailbox] = cf2.Name
rst![Control] = C.UserProperties("Control")
rst![mailbox] = cf2.Name
rst![Description] = C.UserProperties("Description")
rst![mailbox] = cf2.Name
rst![Update] = C.UserProperties("Update")
rst![mailbox] = cf2.Name
rst![Dealing] = C.UserProperties("Dealing")
rst![mailbox] = cf2.Name
rst.Update
Next I
End Function