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

sendobject 2501 email problem

Status
Not open for further replies.

fsweb2002

Programmer
Apr 11, 2002
94
TR
Hello gurus

I have a problem sending an email.
I have form with an email button which creates an email.
All works fine, however if I cancel the email (I don´t send it) for whatever reason, then next time I press the email button to send it again, I get a 2501 error (cancelled) and the email message doesn´t appear.

It happens everytime.
IS like Access 'remembers' there was a cancelled action on first email, and just doesn´t want to "crete" an email after that has happened.

Closing and restarting Access fixes the problem BUT only until a cancel sending an email again, then the problem appears again...

Any ideas ?????
 
It is an very simple process to add the error trap and continue automatically after the 2501 error. There are other ways to accomplish the same thing but this is so easy I don't care to concern myself with them.

Steve King

On Error GoTo HandleErr

' Procedure body

HandleErr:
Select Case Err.Number
Case 2501
Resume Next
Case Else
' Whatever you want to do
End Select

Growth follows a healthy professional curiosity
 
scking, thanks for your reply.

Sorry, I forgot to mention I DO have the error handling routine you mentioned, exactly as you put it.

However I still have that problem.
It works FIRST time only, but as soon as I cancel the send, the next time I press the emailsend button it just does nothing. Doesn´t create the email, it looks like just bypasses the routine...

Any ideas???
 
This works for me but I'm using Outlook for my mail here not SendObject. You could always turn off error handling immediately prior to the SendObject and turn it on again afterwards.

On Error Resume Next

' SendObject code

If Err.Number <> 0 Then
'Do whatever you want
End If

On Error GoTo HandleErr

Steve King

------WORKING CODE----------------

Set oMailApp = CreateObject(&quot;Outlook.Application&quot;)
Set oMail = oMailApp.CreateItem(olMailItem)

With oMail
.To = strAddressees
If Len(strCC) > 0 Then
.CC = strCC
End If
.Subject = strSubject
.Body = strBody
.Importance = olImportanceHigh
.Display
'.SenderName = CurrentUser
.Sensitivity = olPrivate
End With

Exit_Proc:
Exit Sub

HandleErr:

Select Case Err.Number
Case 2501 ' Cancel
Case 2287 ' Can't open mail
MsgBox &quot;Unable to send mail. Outlook not open &quot; & vbCrLf _
& &quot;or unavailable for an on-line session.&quot;, vbCritical, MSGTITLE
Case Else
Call HandleTheError(&quot;frmSendMessageDialog&quot;, &quot;cmdSend_Click&quot;, Err)
End Select
Resume Exit_Proc
Resume
Growth follows a healthy professional curiosity
 
thank you

Yes, I found finally there is a bug with the sendobject and your code will fix it, although it only works with Outlook...

Anyone having the same problem as I had please check
thread181-49081 well as this message.

Thanks to all for all the great help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top