Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2011
    Posts
    4

    Unanswered: access to outlook

    I need to (automatically) export text from an Access 2003 report into an Outlook message (like populating the Outlook email with the text from the relevant Access report).
    How could this possibly be done (considering that I am not an Access expert and know even less of VB)
    Thanks for any help

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    Firstly, is there a reason why you can't mail the report as a whole? It would be a lot simpler.

    Anyway, if I assume correctly, you are trying to take the values of a text box, and automatically create an email which includes that information.

    There's a pretty simple sub that you can place into the load event of your report. I'm assuming you know how to get this far but if not just ask.

    For the benefit of making it as simple as possible for you, I've assumed that the To/ CC/ BCC email addresses, and the Subject line will all be hardcoded, and the text box containing all your information is Text01


    Option Explicit

    Private Sub Report_Load()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim BodyString As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    BodyString = Text01.value

    On Error Resume Next

    With OutMail
    .To = "The Send To Email Address should go here"
    .CC = "The CC Email Address should go here"
    .BCC = "The BCC Email Address should go here"
    .Subject = "The Subject Line should go here"
    .body = BodyString
    '.Attachments.Add ("enter the path for attachment here")
    .Display 'or use .Send to send it without checking
    .ReadReceiptRequested = False 'o use True if you want a read receipt


    End With

    On Error GoTo 0

    Set OutMail = Nothing

    Set OutApp = Nothing

    End Sub

    Last edited by christyxo; 06-09-11 at 10:21.

  3. #3
    Join Date
    Jun 2011
    Posts
    4
    yea...that would be great actually..
    so what do i need to do if i need to send the report as a whole, like an attachment ??
    My boss basically wants me to generate a report,and make a button to then transport that report to an new email in outlook (where to and cc are entered manually). the report can be as an attachment or the data transported as text in email.
    Whichever is simpler.
    thanks a lot for your help

  4. #4
    Join Date
    Oct 2003
    Location
    London
    Posts
    341

    Email Report

    Ok, This will send the report as an attachment in whatever format you assign within the code as OutputFormat. You might need to play around with these.. RTF will attempt to maintain the format but does lose some of it, SNP works fine so long as the person recieving it has snapviewer installed. I was never aware that PDF was an avaliable format so can't comment on this. Try all 3 and see what works best for you.


    Private Sub EmailReport_Click()

    On Error GoTo Err_EmailReport_Click

    Dim BodyString

    BodyString = "Dear x, " _
    & vbcrlf _
    & vbcrlf _
    & "Please find attached x report...blah blah"

    '
    ' DoCmd.SendObject OutputType, ObjectName, OutputFormat, To, CC, BCC, Subject, MessageText, EditMessage, TemplateFile
    '
    ' ObjectType = for this purpose leave it as acSendReport... you can also amend it to send tables, queries, forms etc.
    ' ObjectName = This is the name of the Report that you want to send out... It has to match exactly.
    ' OutputFormat = acFormatPDF, acFormatRTF, or acFormatSNP.
    ' EditMessage = True to edit message before sending, False to send automatically.
    ' TemplateFile = I actually don't know how to use this so never bother including it.
    '

    DoCmd.SendObject acSendReport, "Report Name", acFormatPDF, "To Email Address", "CC Email Address", "Bcc Email Address", "Subject", BodyString, False

    Exit_EmailReport_Click:
    Exit Sub

    EmailReport_Click:
    MsgBox Err.Description
    Resume Exit_EmailReport_Click

    End Sub
    Last edited by christyxo; 06-09-11 at 07:15.

  5. #5
    Join Date
    Jun 2011
    Posts
    4
    thanks sooo much !!
    it worked wonderfully

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •