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

Automated email problem from Access thru Outlook

Status
Not open for further replies.

merlynsdad

Programmer
Nov 18, 2010
175
0
0
US
I'm trying to have Access vba send an automated email. Our mail client is Outlook, and its' security throws up three message boxes during the process, where a YES button must be clicked.

I've tried SendKeys, which just froze the whole system. I've heard of third party apps that can be used to get past this security, but that isn't possible here. Does anyone know of a way to get past this security "feature" using just vba? Thanks in advance.

If the square peg won't fit in the round hole, sand off the corners.
 
Does it need to go through outlook? My automation for e-mails uses a script that you can find here.
It works fairly nicely, because I don't have any outlook issues of any kind. I send out about 100 auto reports a week this way.

ChaZ

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.

 
Good put Chaz. I found and implemented the same method and now I use it for all my Access / outlook emailing. You can also add .cc and .bcc, but I have not found a need yet. Here is my implementation of it:

Code:
Sub SendEmail(sSubject As String, sTo As String, sFrom As String, sMsg As String, Optional sAttachment As String)

'need reference to ms cdo library

Dim objMsg As Object

Dim iConf As Object
Dim flds As Variant
Set objMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
    iConf.Load -1
    Set flds = iConf.Fields
    With flds
            .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
            .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] _
                           = "Put your exchange server.domain.com here"
            .Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
            .Update
    End With
    With objMsg
    Set .Configuration = iConf
        .Subject = sSubject
        .From = sFrom
        .To = sTo
        '.CC = sFrom
        'objMsg.Bcc = " email@removed "
        .TextBody = sMsg
        .AddAttachment sAttachment
        .Send
    End With
    

Set objMsg = Nothing

End Sub
 
It is better to bypass Outlook altogether so that the emails will go out smoothly without any message box. DocumentBurster is good software which can easily distribute Microsoft Access reports by email and does not need Outlook. Also the software is trivial to set up and there is no need of any kind of coding - not even VBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top