Results 1 to 4 of 4
  1. #1
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563

    Inserting paragraphs in Body of EMail

    Hi Everyone



    With help from other members I currently have the following Code which sends an Email with 2 Reports as attachments.

    The Code:-

    Code:
    Private Sub cmdPDFEMail_Click()
     
        On Error GoTo cmdPDFEMail_Click_Error
        Dim strSQL As String
        Dim objOutlookAttach As Object
        Dim objApp As Object
        Dim objMailItem As Object
        Dim strAttachmentPDF As String
        Dim strAttachmentREP  As String
        Dim strMailItem As String
        Dim strWhere As String
        Dim strToWhom As String
        Dim strMsg As String
        Dim strSubject As String
        '
        '   ======================= Set up all your variables =========================
        strWhere = "[CustomerID]=" & Me.CustomerID
        strToWhom = Me.Email
        strSubject = "PDF Guide"
        strMsg = "Find attached details of CARI Setup Process"
           'Set your PDF path here
        strAttachmentPDF = "C:\PDF\CreateCARIAccount.pdf"
        'Set the report path here
        strAttachmentREP = Application.CurrentProject.Path & "\rptCariProviderLetter_" & Me.CustomerID & ".pdf"
       
        'Application.FollowHyperlink strAttachmentPDF - use to check that the file exists
        'Exit Sub
            
        '   ========================= 'create the report ==============================
     
        DoCmd.OpenReport "rptCariProviderLetter", acViewPreview, , strWhere, acHidden
        DoCmd.OutputTo acOutputReport, "rptCariProviderLetter", acFormatPDF, strAttachmentREP
        DoCmd.Close acReport, "rptCariProviderLetter", acSaveNo
        '
        '   ========================= Now do some outlook stuff ! ===================
       
        Set objApp = CreateObject("outlook.application")
        Set objMailItem = objApp.CreateItem(0)
        objMailItem.Subject = strSubject
        objMailItem.To = strToWhom
        objMailItem.Body = strMsg
       
        'add the pdf
        objMailItem.Attachments.Add strAttachmentREP
        'now lets attach the report
        objMailItem.Attachments.Add (strAttachmentPDF)
       
        objMailItem.Display 'change to .Send if you want to just send it.
       
        On Error GoTo 0
        Exit Sub
     
    cmdPDFEMail_Click_Error:
     
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdPDFEMail_Click, line " & Erl & "."
     
    End Sub
    I now need to add the following into the Body of the Email as Text Paragraphs:-

    MyMsg = MyMsg
    MyMsg = "Onboarding Announcement:" & vbCrLf
    MyMsg = MyMsg & "As a part of the Onboarding process, please ensure that the below two-step process" & vbCrLf
    MyMsg = MyMsg & "is completed for your CARI account. " & vbCrLf
    MyMsg = MyMsg & "Step 1: Create a CARI Account." & vbCrLf & vbCrLf
    MyMsg = MyMsg & "(FYI: Use the link in the attached letter to create your account and not the below link in this email" & vbCrLf

    Where would I insert these lines?

    Any help appreciated
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    code before...
    strSubject = "PDF Guide"
    strMsg = "Find attached details of CARI Setup Process" & vbCrLf
    strMsg= "Onboarding Announcement:" & vbCrLf
    strMsg= strMsg& "As a part of the Onboarding process, please ensure that the below two-step process" & vbCrLf
    strMsg= strMsg& " is completed for your CARI account. " & vbCrLf
    strMsg= strMsg& "Step 1: Create a CARI Account." & vbCrLf & vbCrLf
    strMsg= strMsg& "(FYI: Use the link in the attached letter to create your account and not the below link in this email)"
    code after...

    You have variables declared that you're not even using here?
    IIRC, you don't have to open a report in order to send it with SendObject
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi Micron

    Many thanks that works a treat
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Glad to help. Good luck with your project.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. email a form in the body of an email?
    By rudyebiii in forum Forms
    Replies: 2
    Last Post: 10-08-2016, 07:58 AM
  2. Replies: 3
    Last Post: 05-18-2015, 11:24 AM
  3. Email report as body of email (RTF)
    By TheDeceived in forum Programming
    Replies: 4
    Last Post: 07-23-2012, 06:39 AM
  4. Email report as body of email
    By chrish20202 in forum Programming
    Replies: 6
    Last Post: 01-15-2012, 07:23 PM
  5. Email from report to Email body
    By Ehmke66 in forum Programming
    Replies: 4
    Last Post: 01-03-2011, 01:06 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