When attempting to send an e-mail using the following code, Outlook hangs up when the .Send attempts to execute. After clicking anywhere on my open Access form, I receive this error message :
This action cannot be completed because the Microsoft Outlook application (Microsoft Outlook) is not responding. Choose Switch To to activate Microsoft Outlook and correct the problem.
After clicking on 'Switch to' (and the Outlook Security Update warning) the e-mail is successfully transmitted. Subsequent attempts to send e-mails do not produce this error. In fact, if Outlook is closed prior to opening Access, I don't get the error
CODE-
Public Sub SendMessage(Optional AttachmentPath)
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application"
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(0) 'olMailItem
' Set To, CC, BCC, Subject, Body, and Importance of the message.
objOutlookMsg.To = DLEC_TO
objOutlookMsg.CC = DLEC_CC
objOutlookMsg.BCC = DLEC_BCC
objOutlookMsg.Subject = DLEC_SUBJECT
objOutlookMsg.Body = DLEC_MESSAGE & vbCrLf & vbCrLf
objOutlookMsg.Importance = 2 'High importance
objOutlookMsg.Send
'Close Outlook
objOutlook.Quit
Set objOutlookMsg = Nothing
End Sub
This action cannot be completed because the Microsoft Outlook application (Microsoft Outlook) is not responding. Choose Switch To to activate Microsoft Outlook and correct the problem.
After clicking on 'Switch to' (and the Outlook Security Update warning) the e-mail is successfully transmitted. Subsequent attempts to send e-mails do not produce this error. In fact, if Outlook is closed prior to opening Access, I don't get the error
CODE-
Public Sub SendMessage(Optional AttachmentPath)
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application"
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(0) 'olMailItem
' Set To, CC, BCC, Subject, Body, and Importance of the message.
objOutlookMsg.To = DLEC_TO
objOutlookMsg.CC = DLEC_CC
objOutlookMsg.BCC = DLEC_BCC
objOutlookMsg.Subject = DLEC_SUBJECT
objOutlookMsg.Body = DLEC_MESSAGE & vbCrLf & vbCrLf
objOutlookMsg.Importance = 2 'High importance
objOutlookMsg.Send
'Close Outlook
objOutlook.Quit
Set objOutlookMsg = Nothing
End Sub