none
Access 2010 DoCmd.SendObject hangs after send with Outlook 2016 RRS feed

  • Question

  • I have recently noticed that sending an email, using DoCmd.SendObject, from Access 2010 runtime to Outlook 2016, causes Access 2010 runtime (and full version as well) to hang after the message is sent. It looks like control is never handed back after the message window closes. I have tried closing Outlook, without any improvement.  The only way to get past this is to close Access 2010 from the Task Manager.

    I have seen this at a customer site and also been able to reproduce the problem locally. The workaround I have found is to use Access 2016 runtime. Is there a solution where I can avoid using Access 2016?


    • Edited by Mor10 Monday, February 15, 2016 10:55 PM
    Monday, February 15, 2016 10:55 PM

Answers

  • Your best bet is to use the 2016 Runtime.

    Just takes a click to give thanks for a helpful post or answer.
    Please vote “Helpful” or Mark as “Answer” as appropriate.
    Chris Ward
    Microsoft Community Contributor 2012

    • Marked as answer by David_JunFeng Wednesday, February 24, 2016 9:36 AM
    Tuesday, February 16, 2016 4:30 PM
  • >>>I have recently noticed that sending an email, using DoCmd.SendObject, from Access 2010 runtime to Outlook 2016, causes Access 2010 runtime (and full version as well) to hang after the message is sent. It looks like control is never handed back after the message window closes. I have tried closing Outlook, without any improvement.

    According to your description, as far as I know that SendObject method has several significant limitations:

    1. Messages must be 255 characters or less
    2. Messages are plain text and cannot be HTML format
    3. Cannot attach multiple files (limited to one attachment)
    4. Cannot attach a file on disk
    5. Cannot filter the data source or report to just the data you need to send
    6. Cannot specify the FROM address
    7. Cannot specify settings such as priority, sensitivity, and read receipt
    8. MAPI security dialog box prompts the user for each email to verify it is okay to send
    9. Doesn't always work with email programs if it's not Outlook, Outlook Express, or Exchange

    So I suggest that you could use the OutputTo method to output the data in the specified Access database object (a datasheet, form, report, module, data access page) to several output formats, then create and send an mail.

    How to use Automation to create and send a Microsoft Outlook message in Microsoft Access, refer to codes below:

    Tools menu, click References, in the References box, choose the Microsoft Outlook X.0 Object Model

    Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
              Dim objOutlook As Outlook.Application
              Dim objOutlookMsg As Outlook.MailItem
              Dim objOutlookRecip As Outlook.Recipient
              Dim objOutlookAttach As Outlook.Attachment
    
              ' Create the Outlook session.
              Set objOutlook = CreateObject("Outlook.Application")
    
              ' Create the message.
              Set objOutlookMsg  = objOutlook.CreateItem(olMailItem)
    
              With objOutlookMsg
                  ' Add the To recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
                  objOutlookRecip.Type = olTo
    
                  ' Add the CC recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Michael Suyama")
                  objOutlookRecip.Type = olCC
    
                 ' Add the BCC recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
                  objOutlookRecip.Type = olBCC
    
                 ' Set the Subject, Body, and Importance of the message.
                 .Subject = "This is an Automation test with Microsoft Outlook"
                 .Body = "This is the body of the message." &vbCrLf & vbCrLf
                 .Importance = olImportanceHigh  'High importance
    
                 ' Add attachments to the message.
                 If Not IsMissing(AttachmentPath) Then
                     Set objOutlookAttach = .Attachments.Add(AttachmentPath)
                 End If
    
                 ' Resolve each Recipient's name.
                 For Each ObjOutlookRecip In .Recipients
                     objOutlookRecip.Resolve
                 Next
    
                 ' Should we display the message before sending?
                 If DisplayMsg Then
                     .Display
                 Else
                     .Save
                     .Send
                 End If
              End With
              Set objOutlook = Nothing
    End Sub
    

    For more information, click here to refer about Using Automation to Send a Microsoft Outlook Message

    • Marked as answer by David_JunFeng Wednesday, February 24, 2016 9:36 AM
    Wednesday, February 17, 2016 5:30 AM

All replies

  • Your best bet is to use the 2016 Runtime.

    Just takes a click to give thanks for a helpful post or answer.
    Please vote “Helpful” or Mark as “Answer” as appropriate.
    Chris Ward
    Microsoft Community Contributor 2012

    • Marked as answer by David_JunFeng Wednesday, February 24, 2016 9:36 AM
    Tuesday, February 16, 2016 4:30 PM
  • >>>I have recently noticed that sending an email, using DoCmd.SendObject, from Access 2010 runtime to Outlook 2016, causes Access 2010 runtime (and full version as well) to hang after the message is sent. It looks like control is never handed back after the message window closes. I have tried closing Outlook, without any improvement.

    According to your description, as far as I know that SendObject method has several significant limitations:

    1. Messages must be 255 characters or less
    2. Messages are plain text and cannot be HTML format
    3. Cannot attach multiple files (limited to one attachment)
    4. Cannot attach a file on disk
    5. Cannot filter the data source or report to just the data you need to send
    6. Cannot specify the FROM address
    7. Cannot specify settings such as priority, sensitivity, and read receipt
    8. MAPI security dialog box prompts the user for each email to verify it is okay to send
    9. Doesn't always work with email programs if it's not Outlook, Outlook Express, or Exchange

    So I suggest that you could use the OutputTo method to output the data in the specified Access database object (a datasheet, form, report, module, data access page) to several output formats, then create and send an mail.

    How to use Automation to create and send a Microsoft Outlook message in Microsoft Access, refer to codes below:

    Tools menu, click References, in the References box, choose the Microsoft Outlook X.0 Object Model

    Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
              Dim objOutlook As Outlook.Application
              Dim objOutlookMsg As Outlook.MailItem
              Dim objOutlookRecip As Outlook.Recipient
              Dim objOutlookAttach As Outlook.Attachment
    
              ' Create the Outlook session.
              Set objOutlook = CreateObject("Outlook.Application")
    
              ' Create the message.
              Set objOutlookMsg  = objOutlook.CreateItem(olMailItem)
    
              With objOutlookMsg
                  ' Add the To recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
                  objOutlookRecip.Type = olTo
    
                  ' Add the CC recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Michael Suyama")
                  objOutlookRecip.Type = olCC
    
                 ' Add the BCC recipient(s) to the message.
                  Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
                  objOutlookRecip.Type = olBCC
    
                 ' Set the Subject, Body, and Importance of the message.
                 .Subject = "This is an Automation test with Microsoft Outlook"
                 .Body = "This is the body of the message." &vbCrLf & vbCrLf
                 .Importance = olImportanceHigh  'High importance
    
                 ' Add attachments to the message.
                 If Not IsMissing(AttachmentPath) Then
                     Set objOutlookAttach = .Attachments.Add(AttachmentPath)
                 End If
    
                 ' Resolve each Recipient's name.
                 For Each ObjOutlookRecip In .Recipients
                     objOutlookRecip.Resolve
                 Next
    
                 ' Should we display the message before sending?
                 If DisplayMsg Then
                     .Display
                 Else
                     .Save
                     .Send
                 End If
              End With
              Set objOutlook = Nothing
    End Sub
    

    For more information, click here to refer about Using Automation to Send a Microsoft Outlook Message

    • Marked as answer by David_JunFeng Wednesday, February 24, 2016 9:36 AM
    Wednesday, February 17, 2016 5:30 AM