Sending Emails With Windows 11 Office 365 (New Outlook)

lhooker

Registered User.
Local time
Today, 17:29
Joined
Dec 30, 2005
Messages
431
I'm told that Access email function does not work with Windows 11 Office 365 (New Outlook). I get the 'An error occurred while attempting to send the email. Error '2293' Microsoft Access can't send this email.' error message. Is there anyway to run my VBA email routine. My laptop does not have the Outlook Classic version and I don't feel comfortable uninstalling and reinstalling Outlook.
 
No, New Outlook does not support COM automation. You can not send email from Access to New Outlook because of that.

There are alternatives, including reinstalling what they now refer to as Classic Outlook.

You can explore other options here:


and here

 
If you are just sending, there is also CDO. Plenty of examples if you google - here’s one
I'm not familiar with the required information. Is this information found in my email account ?

i.e. => Requires knowledge of all the server settings (port, username, password, authentication
 
I'm not familiar with the required information. Is this information found in my email account ?

i.e. => Requires knowledge of all the server settings (port, username, password, authentication
You should be able to get the server settings from your Exchange Server admin or your IT department.
 
No, New Outlook does not support COM automation. You can not send email from Access to New Outlook because of that.

There are alternatives, including reinstalling what they now refer to as Classic Outlook.

You can explore other options here:


and here

I have trouble trying signin/signup for Power Automate. I see it listed in my Microsoft apps, but get into Power Automate. It rejects my Microsoft signin.
 
Save yourself weeks of frustration and just use Oulook classic. I use Windows 11 with both versions installed. I went back to classic for my default version because the web version is just not worth it. But if you are using Office automation Outlook clasic is required and a 1000 times easier than CDO.
 
Concur with LarryE, with the caveat that Outlook Classic might be hard to find in order to download it, depending on which version of Office you are using. I've seen a few questions on this forum regarding Outlook 365 and how sometimes it is difficult because MS is pushing people away from Outlook Classic. In fact, that's why I downloaded an LTSC version of Office when my old machine died and I had to update away from Ofc2010.
 
for CDO
Account is your email address or user name
for sending, Server will be something like smtp.gmail.com
Port will be something like 465
Authentication is your password

some email servers require what is called an app password, all depends

Basically the same information as when you set up outlook
 
I don't know about Comcast.net but my Yahoo, Gmail, and email accounts wouldn't allow my passwords. I had to set up a special passkey with each one, then it worked great . This information is stored in a table. I'm not at my desk , later I can share the code.
 
Save yourself weeks of frustration and just use Oulook classic. I use Windows 11 with both versions installed. I went back to classic for my default version because the web version is just not worth it. But if you are using Office automation Outlook clasic is required and a 1000 times easier than CDO.
I downloaded "OfficeSetup,Exe" from the Microsoft website. I will assume this will give me Microsoft Outlook Classic with the option to switch between Microsoft Outlook Classic and New Outlook. Will this cause any problems with my emails ?
 
I downloaded "OfficeSetup,Exe" from the Microsoft website. I will assume this will give me Microsoft Outlook Classic with the option to switch between Microsoft Outlook Classic and New Outlook. Will this cause any problems with my emails ?
If you are going to use Outlook classic with Office automation, then classic needs to be the only e-mail product on your Toolbar. That way classic version will always open as default. Put the classic version on the Toolbar and delete New Outlook from the Toolbar. Also, using office automation, a classic instance needs to be opened first before any automation procedures can be performed. So, if you are using a WORD document for example, to send bulk e-mails, an instance of classic Outlook needs to be opened (I open an instance and then use VBA code to minimize it to the Toolbar), then office automation procedures will work fine. I spent numerous hours a few weeks ago on this subject.
I use the following code to open and minimize Outlook classic called either whenever you wish:
Code:
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As LongPtr, ByVal nCmdShow As Long) As Long
Const SW_HIDE As Long = 0
Const SW_SHOWNORMAL As Long = 1
Const SW_SHOWMINIMIZED As Long = 2
Const SW_SHOWMAXIMIZED As Long = 3
Const SW_SHOWNOACTIVATE As Long = 4
Const SW_SHOW As Long = 5
Const SW_MINIMIZE As Long = 6
Const SW_SHOWMINNOACTIVE As Long = 7
Const SW_SHOWNA As Long = 8
Const SW_RESTORE As Long = 9
Const SW_SHOWDEFAULT As Long = 10
Const SW_FORCEMINIMIZE As Long = 11
Dim RetVal As LongPtr
RetVal = ShellExecute(0, "open", "outlook.exe", vbNullString, vbNullString, 7)
I was using a WORD document to send bulk e-mails using its Mail merge function linked to an ACCESS query to retrieve names and e-mail addresses but if you are using ACCESS, then opening and minimizing Outlook would work the same way.

Then when I am through sending mail, I close the instance of Outlook with:
Code:
Dim RetVal As Long
RetVal = Shell("taskkill /F /IM outlook.exe", vbHide)
 
Last edited:
CDO code:

Code:
Sub SetUpEmail()
    gstrSubject = [Forms]![frmEventsNImages]![EventName]
    gstrFrom = [Forms]![frmEventsNImages]![EventEmail]
    gstrTo = Me.ShareTo.Text
    gstrBody = [Forms]![frmEventsNImages]![EventMessage]
    gstrAttachment = Me.ImagePath.Value & "\" & Me.ImageName.Value
    
    gstrPort = [Forms]![frmEventsNImages]![ServerPort]
    gstrUsing = [Forms]![frmEventsNImages]![SendUsing]
    gstrAuthenticate = [Forms]![frmEventsNImages]![SMTPAuthenticate]
    gintTimeOut = [Forms]![frmEventsNImages]![Timeout]
    gstrUseSSL = [Forms]![frmEventsNImages]![UseSSL]
    gstrPassword = [Forms]![frmEventsNImages]![EventEmailPassword]
    gstrServer = [Forms]![frmEventsNImages]![EmailServer]
End Sub

Code:
Public Sub CDO_Email()
On Error GoTo Err_ErrorHandler
    Dim CDO_Mail As Object
    Dim CDO_Config As Object
    Dim SMTP_Config As Variant
    
    gblnEmailFailed = False
    
    Set CDO_Mail = CreateObject("CDO.Message")

    Set CDO_Config = CreateObject("CDO.Configuration")
    CDO_Config.Load -1

    Set SMTP_Config = CDO_Config.Fields

    With SMTP_Config
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = gstrUsing
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = gstrServer
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = gstrAuthenticate
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = gstrFrom
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = gstrPassword
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = gstrPort
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = gstrUseSSL
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = gintTimeOut

      'code for STARTTLS
        If txtPort = 587 Then
            .Item("http://schemas.microsoft.com/cdo/configuration/sendtls").Value = True
        End If
        .Update
    End With

    With CDO_Mail
        Set .Configuration = CDO_Config
    End With

    With CDO_Mail
        .Subject = gstrSubject
        .From = gstrFrom
        .To = gstrTo
        .TextBody = gstrBody
        If Len(gstrAttachment) > 0 Then
            .AddAttachment (gstrAttachment)
        End If
        .Send
    End With
    Set SMTP_Config = Nothing
    Set CDO_Mail = Nothing
 
Exit_ErrorHandler:
'Access 2007 Developer Reference > Microsoft Data Access Objects (DAO) Reference > DAO Reference > Recordset Object > Methods
'An alternative to the Close method is to set the value of an object variable to Nothing (Set dbsTemp = Nothing).
    Exit Sub

Err_ErrorHandler:
    If Err.Number <> 0 Then
        Select Case Err.Number

            Case -2147220977  'Likely cause, Incorrectly Formatted Email Address, server rejected the Email Format
                MsgBox "Error From --- fSendGmail --- Incorrectly Formatted Email ---  Error Number >>>  " _
                & Err.Number & "  Error Desc >>  " & Err.Description, , "Format the Email Address Correctly"

            Case -2147220980  'Likely cause, No Recipient Provided (No Email Address)
                MsgBox "Error From --- fSendGmail --- No Email Address ---  Error Number >>>  " _
                & Err.Number & "  Error Desc >>  " & Err.Description, , "You Need to Provide an Email Address"

            Case -2147220960 'Likely cause, SendUsing Configuration Error
                MsgBox "Error From --- fSendGmail --- The SendUsing configuration value is invalid --- LOOK HERE >>> sendusing) = conCdoSendUsingPort ---  Error Number >>>  " _
                & Err.Number & "  Error Desc >>  " & Err.Description, , "SendUsing Configuration Error"

            Case -2147220973  'Likely cause, No Internet Connection
                MsgBox "Error From --- fSendGmail --- No Internet Connection ---  Error Number >>>  " _
                & Err.Number & "  Error Desc >>  " & Err.Description, , "No Internet Connection"

            Case -2147220975  'Likely cause, Incorrect Password
                MsgBox "Error From --- fSendGmail --- Incorrect Password ---  Error Number >>>  " _
                & Err.Number & "  Error Desc >>  " & Err.Description, , "Incorrect Password"

            Case Else   'Report Other Errors
                MsgBox "Error From --- fSendGmail --- Error Number >>>  " & Err.Number _
                & "  <<< Error Description >>  " & Err.Description
        End Select
    gblnEmailFailed = True
    Resume Exit_ErrorHandler
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom