Discussion:
Send Email using SendObject fails when sending more than one time.
(too old to reply)
robboll
2009-12-21 17:53:11 UTC
Permalink
Hello! The routine below works great when I send only one email. But
when
I send another email, I have to kill Outlook via Task Manager where it
is
immediately replaced by another session of Outlook and Outlooks again
comes up.

Any help with this greatly appreciated!

Rbollinger

=========================================================
Sub Send SendEmail()

On Error GoTo Err_Command11_Click

Dim stDocName, mTO, mCC, mSubject As String

stDocName = "frmSnapShot"
mTO = Forms!frmEmail!emailTO
mCC = Forms!frmEmail!emailCC
mSubject = Forms!frmEmail!Subject
mpath = Mid(Forms!frmIssues!FolderPath, InStr(1, Nz(Forms!
frmIssues!FolderPath), "#") + 1, 100)

DoCmd.SendObject acReport, stDocName, , mTO, mCC, , mSubject, IIf
(Forms!frmEmail!Check3 = -1, "Shared Directory:" & vbCrLf & mpath,
""), , False


Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description

Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: "
& Err.Description
Resume Error_out
Error_out:


End Sub
Ken Slovak - [MVP - Outlook]
2009-12-22 14:08:05 UTC
Permalink
DoCmd uses Simple MAPI, which can be problematic at times with Outlook. Do
you get an Outlook window with the DoCmd call? Usually you get a modal mail
window that when sent will allow the Outlook session in the background to
close.

In general you are always better off using the Outlook object model and
Outlook automation, rather than using Simple MAPI commands.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
Post by robboll
Hello! The routine below works great when I send only one email. But
when
I send another email, I have to kill Outlook via Task Manager where it
is
immediately replaced by another session of Outlook and Outlooks again
comes up.
Any help with this greatly appreciated!
Rbollinger
=========================================================
Sub Send SendEmail()
On Error GoTo Err_Command11_Click
Dim stDocName, mTO, mCC, mSubject As String
stDocName = "frmSnapShot"
mTO = Forms!frmEmail!emailTO
mCC = Forms!frmEmail!emailCC
mSubject = Forms!frmEmail!Subject
mpath = Mid(Forms!frmIssues!FolderPath, InStr(1, Nz(Forms!
frmIssues!FolderPath), "#") + 1, 100)
DoCmd.SendObject acReport, stDocName, , mTO, mCC, , mSubject, IIf
(Forms!frmEmail!Check3 = -1, "Shared Directory:" & vbCrLf & mpath,
""), , False
Exit Sub
MsgBox Err.Description
Exit Sub
MsgBox "An error was encountered." & vbCrLf & "The error message is: "
& Err.Description
Resume Error_out
End Sub
Loading...