Outlook and Application-defined error

C

Col

Hi all,

I have some plain vanilla code to create an email with vba.
On other machines it works fine, but on my machine it returns a 287 error
(Application-defined or object defined error)
This error occurs whenever I try to set the recipient type or resolve
recipients.
If I step through the code (F8) it works first time.
Could my exchange account be corrupted causing timeouts?

Regards

Colin
 
C

Col

I should have mentioned... Its an Access 2000 application that creates an
email.

Regards

Colin
 
C

Col

Solved in a fashion.

I think the Outlook security patch (892843) causes a slow response to the
access to recipient details... could be wrong though.
I catch the 287 error and resume and it finally works OK.

Please let me know if I'm off track here.

Regards

Colin
 
T

Tony Toews

Col said:
I have some plain vanilla code to create an email with vba.
On other machines it works fine, but on my machine it returns a 287 error
(Application-defined or object defined error)
This error occurs whenever I try to set the recipient type or resolve
recipients.
If I step through the code (F8) it works first time.
Could my exchange account be corrupted causing timeouts?

What version of Outlook are you running on your system compared to the
other systems? Also please post your code. What are your
references compared to the other machines?

I'm not at all sure why stepping through your code would work though.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
C

Col

Hi Tony,
An extra bit of info:- If I dump the security patch 892843 it works as
expected but 892843 needs to be installed doesn't it?
If I comment out the trouble spots it works
OK which is not OK really is it?
Here is the code, same as most examples. With the error trapping it will
work after trying a few times.... not very good fix though.

Sub CheckForNewIncidents()
On Error GoTo Err_CheckForNewIncidents

Dim intICNT As Integer
Dim intACTCNT As Integer
Dim intINUM As Integer
Dim intI As Integer
Dim intX As Integer

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim str_Recipients As String
Dim str_SubjectText As String
Dim str_BodyText As String
Dim AttachmentPath As String
Dim DisplayMSG As Boolean

DisplayMSG = True

intACTCNT = getIncidentCount(2)

If intACTCNT > 0 Then
'Find the incident
For intI = 1 To intACTCNT
intINUM = GetNewIncidentNumber()
If intINUM = 0 Then
Exit Sub
Else
str_Recipients =
GetSupervisorEmailAddress(GetSupervisor(intINUM))

str_SubjectText = "Helpdesk request from " &
GetRequester(intINUM)

str_BodyText = "The problem is " & GetIncidentText(intINUM)
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(str_Recipients)
With objOutlookRecip
'
.Type = olTo
'has trouble here
End With
'
' Set the Subject, Body, and Importance of the message.
.Subject = str_SubjectText
.Body = str_BodyText
.Importance = olImportanceNormal 'High importance

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
'
objOutlookRecip.Resolve
'and here
Next
'

' Should we display the message before sending?
If DisplayMSG Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
intX = SetIncident(1, intINUM)
If intX <> 0 Then
MsgBox "Update Failed", vbOKOnly, "TABLE WRITE FAILURE"
End If
End If
Next
End If

Exit_CheckForNewIncidents:
Exit Sub

Err_CheckForNewIncidents:
If Err.Number = 287 Then
Resume
Else
MsgBox Err.Number & " " & Err.Description, 48, "ERROR DETECTED"
Resume Exit_CheckForNewIncidents
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top