Results 1 to 9 of 9
  1. #1
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295

    Sending a value from Access to Outlook email

    Good Day All,

    On the PRINT PREVIEW tab of Access, selecting the email button sends the report directly to Outlook. At this point the From field in Outlook contains the assigned value from Access. However there is no value in the To field.

    I want a way for the To field to be automatically populated with a value which I have in access.



    Is this idea possible?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    docmd.SendObject acSendReport ,"rMyReport",acFormatPDF,sTo,,,sSubj,sBody

  3. #3
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295
    Thanks.

    Since I am using the Access menu button, where would I write this code?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    It would be in button Click event on form. Or report in ReportView can trigger its own event code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295
    The report is actually an Invoice which is generated on the fly but perishes on closed. So I cant use a form. Therefore how can the temporary report generate the event?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    What do you mean by 'generated on the fly'? How is a report 'temporary'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295
    ok.

    The invoices are reports that are created when needed; the data is always there in tables, but it is only through a query that invoices are created based on the Invoice ID that is supplied at the time. Only one invoice can be generate at a time. If another invoice is to be generated then the one that is open must first be closed. so in that way an instance of an invoice is only temporary.

    Also, when the order-form is opened a button on the form is clicked to open the associated the associated invoice. So that is what is referred to a on the fly; in other words the invoice is created only while the form is open first.

    Now here is what I need assistance with: when the invoice is open how can I access a form to press a button to send that invoice to an email. I would have to close the Invoice first and then I cannot reference it to send the email because it would no longer be available.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    That is routine process.

    Consider the following example code:

    Private Sub Command137_Click()
    DoCmd.OpenReport "Invoice", acViewPreview, , "InvoiceID=" & Me.InvoiceID
    DoCmd.SendObject acSendReport, "Invoice", acFormatPDF, "email address", , , "Test", "See Attached"
    DoCmd.Close acReport, "Invoice", acSaveNo
    End Sub

    However, it is possible to open a report and then go back to form and report remains open.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295
    Thanks June7,

    This is working perfectly. Saved me a lot of time in research.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-19-2018, 10:38 AM
  2. Replies: 6
    Last Post: 07-28-2017, 09:07 AM
  3. Replies: 3
    Last Post: 06-19-2016, 07:46 AM
  4. sending email from outlook
    By darwish in forum Programming
    Replies: 1
    Last Post: 04-16-2014, 07:49 AM
  5. Replies: 3
    Last Post: 09-01-2010, 08:43 PM

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