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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Error Numbers?

Status
Not open for further replies.

ChrisCalvert

Technical User
Mar 18, 2002
231
US
I am having a real problem with a function I am using to send emails. It seems to be throwing up random error number when it encounters a single problem, namely "Outlook did not recognize one or more names." The problem is that the
error number seems to be random. I have tracked the error, running the same code, the same table and the error has been different almost every time. ONE time out of about thirty, it repeated. Anyone experienced anything like this?

-chris
 
Here is the code, it is a slightly modified version of that to allow for correcting email addresses. The error handler fires, but show different errors every time....

---------------------------------------------------
Public Function fctnOutlook(Optional FromAddr, Optional Addr, Optional CC, Optional BCC, _
Optional Subject, Optional MessageText, Optional Vote As String = vbNullString, _
Optional Urgency As Byte = 1, Optional EditMessage As Boolean = True)


On Error GoTo Error_Handler
' Code sample from Accessory
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg

If Not IsMissing(FromAddr) Then
.SentOnBehalfOfName = FromAddr
End If

If Not IsMissing(Addr) Then
Set objOutlookRecip = .Recipients.Add(Addr)
objOutlookRecip.Type = olTo
End If

If Not IsMissing(CC) Then
Set objOutlookRecip = .Recipients.Add(CC)
objOutlookRecip.Type = olCC
End If

If Not IsMissing(BCC) Then
Set objOutlookRecip = .Recipients.Add(BCC)
objOutlookRecip.Type = olBCC
End If

If Not IsMissing(Subject) Then
.Subject = Subject
End If

If Not IsMissing(MessageText) Then
.Body = MessageText
End If

If IsNull(Vote) = False Then
.VotingOptions = Vote
End If

Select Case Urgency
Case 2
.Importance = olImportanceHigh
Case 0
.Importance = olImportanceLow
Case Else
.Importance = olImportanceNormal
End Select

For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

If EditMessage Then
.Display
Else
.Save
.Send
End If

End With
Set objOutlook = Nothing

Exit Function

Error_Handler:
MsgBox Err.Number 'Fires, but with...who knows what showing.

End Function
 
Hmmm, that is a great idea.
I guess I was so bent on knocking down the door I didn't see the hole in the wall... Thanks!


-chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top