Results 1 to 3 of 3
  1. #1
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29

    Access SMTP now requires Authentication


    Hi all,

    I had some SMTP emails that were working just fine. But now my organization requires that we use authentication to send out to outside domain emails.

    My working code is as seen below:

    Code:
    Sub SendEmail(sTo As String, sSubject As String, Optional sBody As String, Optional sAttachment As String, Optional sBCC As String)On Error GoTo SendEmail_Err
    Start:
    Set objmessage = CreateObject("CDO.Message")
    With objmessage
        .From = "LV_Reports@orgdomain.org"
        .To = sTo
        .BCC = sBCC
        .Subject = sSubject
        .HTMLBody = sBody
        If sAttachment <> "" Then
            .AddAttachment sAttachment
        End If
        .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.orgserver.org"
        .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Configuration.Fields.Update
        .Send
    End With
    Exit Sub
    SendEmail_Err:
    'MsgBox Err.Number & " is the errror code for this event. " & Err.Description
    If Err.Number = -2147024864 Then
        Shell "TASKKILL /F /IM EXCEL.exe"
        GoTo Start
        'LogError Err.Number, Err.Description & " - " & sAttachment, "SendEmail", , False
    ElseIf Err.Number = -2147220973 Or Err.Number = -2147220975 Then
        GoTo Start
    Else
        LogError Err.Number, Err.Description & " - " & sAttachment, "SendEmail", , False
    End If
    Debug.Print
    End Sub
    I did some research and found that something along the lines of this code needs to be added. But i can't get it to work.

    Code:
        .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1    .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername"
        .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
        .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
    Any ideas how i'm supposed to authenticate via SMTP?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Well for a start you would need to concatenate username and password into those code lines?, and not the literal words?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Have a look at my CDO EMail Tester (isladogs.co.uk) app to help determine the settings you require
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 07-16-2020, 02:52 PM
  2. Replies: 1
    Last Post: 11-15-2017, 08:15 PM
  3. Access User Authentication
    By hi.its.anu in forum Access
    Replies: 1
    Last Post: 08-23-2012, 04:56 PM
  4. Email from Access 2003 with SMTP authentication
    By prstoessel in forum Programming
    Replies: 1
    Last Post: 12-16-2011, 12:07 AM
  5. Windows 7 and smtp mail with Access 2003
    By mafhobb in forum Programming
    Replies: 1
    Last Post: 06-28-2010, 09:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums