Results 1 to 6 of 6
  1. #1
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    53

    Unable to email reports out of Access

    The code below would generate a report and then create an Outlook message with the report attached:

    Code:
    Private Sub btnEMail_Click()
    Dim strEMail As String
    
    Me.Refresh
    strReportCopy = "Copy"
    strInvoiceWhere = "[IvcId]=" & Forms!IvcFrm001!IvcID
    DoCmd.SendObject acSendReport, "IvcFaxRpt01", acFormatPDF
    
    End Sub
    Over the past year, this button has stopped working for certain users. I believe I have it narrowed down to which version of Office is installed on the computer. Users with Office 2016 and 2019 have the Access program crash when the button is clicked. Users with Office 2010 and 2013 have no problem with this button. This led me to information about the Outlook Email Security Update.

    So, before I tell my users that as their computers get upgraded to newer versions of Office, they will have to save the report to a location and then manually open an email and attach the report, is there anyway to still have this process partially automated?



    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    give ALL the parameters:
    DoCmd.SendObject acSendQuery, "qsQuery", acFormatPDF, "name@aol.com", , , "Subject", "message"

  3. #3
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    53
    Quote Originally Posted by ranman256 View Post
    give ALL the parameters:
    DoCmd.SendObject acSendQuery, "qsQuery", acFormatPDF, "name@aol.com", , , "Subject", "message"
    I tried both what you typed and an actual test subject and message. Got the same fail to send error message.
    Is there anything else for me to check?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    It could be that the Office version is why you get variations in success. However, the root of the problem also seems to be that poorly written code balks in newer versions, thus it's not the version, it's the code. I'm seeing more and more of this lately. Put a break on your button code and step through it (usually F8) and watch your values, especially for variables. Don't forget that in order for a variable in a line of code to receive any value, that line has to be executed. It will not be assigned as long as you're on the line (it's highlighted IIRC).

    Maybe you have declared your variables at the top of the module, but if you have we can't see that. If you haven't, it's bad form. Also not evident if your modules contain Option Explicit at the top, which they all should.

    Lastly, always provide the error number and text in your posts. It helps narrow the focus of responses.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    breezett93 is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    53
    Yes, Option Explicit is at the top.
    Error code was 2293, "Can't send this email message". That's what led me to the Outlook Email Security update information.

    I've already done the break testing. It errors out on the DoCmd line. The previous two lines are working properly.

    I didn't build this particular module. It has been working fine for the several years I've been with this company.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I missed that you said Office 2016 and 2019 when I thought you wrote Access 2016 and 2019.
    There seems to be so many possibilities for the fix (as you've no doubt noticed) depending on what was installed over what, whether you're using MAPI or SMTP and so on. I'm afraid that this one is going to take a lot of searching for you where you compare situations against yours because there's too many variables to expect a clear cut answer. The only other thing I can think of is to use CDO if you can gain access to the company mail server. If you're not using a mail server, don't bother looking that up.

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

Similar Threads

  1. Replies: 13
    Last Post: 02-08-2017, 04:11 PM
  2. Unable to save changes to forms, reports.
    By mdnikki in forum Access
    Replies: 3
    Last Post: 12-07-2016, 12:41 PM
  3. Replies: 7
    Last Post: 10-04-2013, 02:26 PM
  4. Replies: 2
    Last Post: 06-25-2013, 05:48 AM
  5. Email Individual Access Reports
    By Nae in forum Reports
    Replies: 3
    Last Post: 08-26-2012, 04:39 PM

Tags for this Thread

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