Results 1 to 6 of 6
  1. #1
    brownpride is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    10

    Exporting Access form to Outlook formatting

    I have been successful in exporting the active record in PDF format to Outlook for e-mail using VBA. I have added text to the email. However when the message text exports to Outlook the 1st line is blank and the text starts on the 2nd line. For example...



    Message Text:
    "Unwanted Empty Line"
    "Dear...."
    ""
    "Please..."

    How can I have the "Dear..." start on the 1st line of the e-mail (instead of the 2nd line) without manually formatting the e-mail?

    Code is below.

    Code:
    Sub Send_Click()Dim strDocName As String
    Dim strWhere As String
        strDocName = "frmInvoice"
        strWhere = "[B]=" & Me.B
        DoCmd.ApplyFilter cPreview, strWhere
    Dim mailto As String
    Dim emailmsg As String
    mailto = [Invoice Contact - E-mail]
    emailmsg = "Dear " & [Invoice Contact - First Name] & " " & [Invoice Contact - Last Name] & "," & vbCrLf & vbLf & _
    "Please..."
    DoCmd.SendObject acSendForm, "frmInvoice", acFormatPDF, mailto, , , mailsub, emailmsg, True
    End Sub

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You want a form or report to appear in the Body of your email? There may be a new fangled way to do this. However, I have always used VBA to generate HTML code and store the HTML code in a String Variable. Then apply that to the Outlook Mail Object's .Body property.

  3. #3
    brownpride is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    10
    Quote Originally Posted by ItsMe View Post
    You want a form or report to appear in the Body of your email? There may be a new fangled way to do this. However, I have always used VBA to generate HTML code and store the HTML code in a String Variable. Then apply that to the Outlook Mail Object's .Body property.
    No, I just want text that I type in. The form is already attached as a .pdf

    I have seen some forums about using outlook mail objects, but I have been unsuccessful at using it while keeping the same exact function.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I am not sure why you are getting that initial line feed and carriage return. There may not be anything you can do about that. If you want to add a carriage return, I would do it the way you are ... vbcr or vbCrLf

    I almost always use automation of Outlook. Here is an example if you are interested.
    https://www.accessforums.net/showthr...258#post281258

  5. #5
    brownpride is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2016
    Posts
    10
    Is there a way to have the PDF attached directly to the e-mail without saving it in a folder first (using the code you linked)?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I do not believe so. I will guess that even the DoCmd will generate the file and store it somewhere in a systems folder prior to moving it to Outlook.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-19-2014, 11:26 AM
  2. Trouble Formatting Outlook Email from Access
    By Nuke1096 in forum Access
    Replies: 6
    Last Post: 11-07-2013, 03:07 PM
  3. Replies: 3
    Last Post: 09-08-2013, 08:50 AM
  4. FORMATTING Outlook Email in BODY of Access code
    By taimysho0 in forum Programming
    Replies: 7
    Last Post: 11-28-2011, 11:04 AM
  5. Replies: 2
    Last Post: 01-24-2010, 09:19 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