• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 506
  • Last Modified:

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?
0
BCreen
Asked:
BCreen
  • 8
  • 2
1 Solution
 
omgangCommented:
Do you want/need to run the messages through Outlook/Exchange?  Do you want/need to keep a copy in the Sent Items folder?  If not then you can use MAPI to send the messages directly without going trhough Outlook.  If you want to send through Outlook then options include the third party software apps (ClickYes, etc.), Outlook Redemption (do a search in EE in the Outlook and Access zones for Redemption).

OM Gang
0
 
omgangCommented:
Sorry, meant to say you can use CDO to send the messages directly.  I'll post up an example shortly.
OM Gang
0
 
omgangCommented:
Give this a try.
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

Open in new window

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
omgangCommented:
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
0
 
BCreenAuthor Commented:
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....
0
 
omgangCommented:
Can you ping the mail server from a command prompt, either by name or IP addy?

OM Gang
0
 
omgangCommented:
Does the SMTP server require login (credentials) to send?

OM Gang
0
 
omgangCommented:
The error you are receiving is most likely due to permissions, or config on the mailserver not accepting the sendmail request (perhaps seeing it as a relay).  Contact the mail server admins and let them know what you are wanting to do.  In my environment the SMTP server accepts and sends the message as long as the sender address is valid for the domain (it won't relay non-domain sender messages).  I have run into a similar issue in a clients environment where Exchange was in use.  The mail server needed to have a setting changed to allow the messages to be sent outside of Exchange.

OM Gang
0
 
BCreenAuthor Commented:
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!
0
 
omgangCommented:
You're welcome.  I'm glad it is working for you.
OM Gang
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now