Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access and outlook

Status
Not open for further replies.

Genie78

MIS
Aug 11, 2008
18
GB
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
 
I cant believe there is no way of doing this...
 
Hi there i was wondering if anyone had ever done anything like the above and had the same type of problems?
 
Hi there the solution i have decided on and ia m only updating here just in case someone ever needs it is


"On Error Resume Next"

Which i add after the name of the mail box

_________

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
On Error Resume Next

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top