BCreen
asked on
Sending emails from an MS Access MDB . . . bypassing Outlook Security...
How do I bypass the message: "A program is trying to automatically send e-mail on your behalf. Do you want to allow this?" This appears when I execute the folowing VBA code:
DoCmd.SendObject , , , "bcreen@American-services- inc.com", , , "Nightly-Run - Your attention is requested!", strMsg, False
strMsg is a message string for the body of the email.
THIS USED TO WORK FINE! I suspect a security patch (for Outlook) no longer allows this. There are 3rd-party "Outlook Security managers" available for purchase, which alegedly allow you to place a few lines of code into your VBA, to bypass this problem.
Is there a way to do this differently, without paying for a 3rd party solution?
DoCmd.SendObject , , , "bcreen@American-services-
strMsg is a message string for the body of the email.
THIS USED TO WORK FINE! I suspect a security patch (for Outlook) no longer allows this. There are 3rd-party "Outlook Security managers" available for purchase, which alegedly allow you to place a few lines of code into your VBA, to bypass this problem.
Is there a way to do this differently, without paying for a 3rd party solution?
Sorry, meant to say you can use CDO to send the messages directly. I'll post up an example shortly.
OM Gang
OM Gang
Give this a try.
OM Gang
OM Gang
Function SendCDOEmail(strFrom As String, strTo As String, strSubj As String, strMsg As String, _
blImportanceHigh As Boolean, blPriorityHigh As Boolean)
'send e-mail message to specified address(es)
On Error GoTo Err_SendCDOEmail
Dim objMessage As Object, objCon As Object
Dim strSMTPGateway As String
strSMTPGateway = "mail.mt.gov"
Set objMessage = CreateObject("CDO.Message")
Set objCon = CreateObject("CDO.Configuration")
objCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPGateway
objCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCon.Fields.Update
Set objMessage.Configuration = objCon
objMessage.Subject = strSubj
objMessage.From = strFrom
objMessage.To = strTo
objMessage.TextBody = strMsg
'check boolean variable to see if we should set importance High for this message
If blImportanceHigh = True Then
objMessage.Fields.Item("urn:schemas:mailheader:importance").Value = "high"
End If
'check boolean variable to see if we should set priority 1 for this message
If blPriorityHigh = True Then
objMessage.Fields.Item("urn:schemas:mailheader:priority").Value = 1
End If
objMessage.Fields.Update
objMessage.Send
Exit_SendCDOEmail:
'destroy object variables
Set objMessage = Nothing
Set objCon = Nothing
Exit Function
Err_SendCDOEmail:
MsgBox Err.Number & ", " & Err.Description, , "Error in function SendCDOEmail"
Resume Exit_SendCDOEmail
End Function
Forgot to add you'll need to change the SMTPGateway variable assignment to the SMTP gateway in your environment. Usually something like mail.MyCompany.com or SMTP.MyCompany.com.
OM Gang
OM Gang
ASKER
Got "-2147220973, The transport failed to connect to the server." from the objMessage.Send line.
I tried mail.amsvcs.com as well as the external ip address 69.xxx.xxx.xxx bother get the same error.
This is such an elegant, simple solution, I hope I can get it to work....
I tried mail.amsvcs.com as well as the external ip address 69.xxx.xxx.xxx bother get the same error.
This is such an elegant, simple solution, I hope I can get it to work....
Can you ping the mail server from a command prompt, either by name or IP addy?
OM Gang
OM Gang
Does the SMTP server require login (credentials) to send?
OM Gang
OM Gang
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Had to use the INTERNAL ip address for the SMTP server and had to be sure that the sender and recipients were all on the mail server (no OUTSIDE email addresses seemed to work, but were not needed anyway).
Thanks so much for yur help!
Thanks so much for yur help!
You're welcome. I'm glad it is working for you.
OM Gang
OM Gang
OM Gang