Results 1 to 4 of 4
  1. #1
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40

    Access Create Email Carriage Return not working?

    Hi,



    I have this VBA code below that works, however, in the message body of my email, all the text comes out in one line, what am I doing wrong?

    I've tried Chr(13), Chr(10), vbCr, vbLF, and vbCrLf? I thought it might be the ".BodyFormat = olFormatRichText" that I commented out, but when I take the comment out, that line I get an error: Run-time error 5 Invalid procedure call or argument?

    In the body of the email I want it to be formatted like this:

    See Attachment:

    Outside Service Report Summary: Vendor Name - 12/5/2018 - 1:17:32 PM - 1st Shipment - RECEIVED


    I hope someone can help!

    Thanks,
    Xavier

    ---------------------------------------

    Dim strEmail As String
    strEmail = Me.txtEmailAddress


    strPath = "P:\AccessDB\Outside Service\Excel_Files" 'Edit to your path
    strFilter = [txtFileName]
    strFile = Dir(strPath & strFilter)


    If strFile <> "" Then


    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)


    With MailOutLook
    ' '.BodyFormat = olFormatRichText
    .To = strEmail
    ''.cc = ""
    ''.bcc = ""
    .Subject = [txtSubjectLine] & " - " & [txtSentReceived]
    .HTMLBody = "See Attachment:" & Chr(13) & Chr(10) & "Outside Service " & [Forms]![frm_01d_Reports]![txtSubjectLine] & _
    " - " & [Forms]![frm_01d_Reports]![txtSentReceived]

    '.HTMLBody = "text here"
    .Attachments.Add (strPath & strFile)
    .Send
    '.Display 'Used during testing without sending (Comment out .Send if using this line)
    End With
    Else
    MsgBox "No file matching " & strPath & strFilter & " found." & vbCrLf & _
    "Processing terminated."
    Exit Sub 'This line only required if more code past End If
    End If

    ---------------------------------------

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    if you dont need html, use:
    .Body = "see attacment.....

  3. #3
    ramirezx@ddmfg.com is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    40
    That did it, thanks!

    Xavier Ramirez

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If you wanted to stick with HTML, you use <BR> within the string instead of the ones you used outside it (vbCrLf, etc).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Carriage return
    By devcon in forum Queries
    Replies: 2
    Last Post: 12-28-2012, 02:56 AM
  2. Replies: 3
    Last Post: 11-22-2012, 08:01 PM
  3. Replies: 1
    Last Post: 02-08-2012, 04:44 PM
  4. Carriage return in a CSV file
    By btidwell3 in forum Import/Export Data
    Replies: 1
    Last Post: 09-09-2011, 05:19 PM
  5. How to force carriage return between strings?
    By Divardo in forum Reports
    Replies: 1
    Last Post: 05-21-2009, 10:50 AM

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