Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Body of Email using Excel (XP)

    I use the following code to automatically send out a spreadsheet.

    <hr>
    Private Sub Mail_workbook_Outlook()
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    With OutMail
    .To = "email@email.com"
    .CC = ""
    .BCC = ""
    .Subject = "Subject goes here"
    .Attachments.Add ActiveWorkbook.FullName
    .Body = "Body goes here"
    .ReadReceiptRequested = True

    .SEnd 'or use .Display
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    <hr>
    Is there a way to have a multiple line body? I need more than one paragraph. When I enter an additional ".body", it picks up the last line and skips the first.

    Also, the attachment is immediately after the body. Is there a way to move it down a couple of spots?

    Thnaks in advance.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Body of Email using Excel (XP)

    Check out this it has plenty of example code

    Steve

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Body of Email using Excel (XP)

    In addition to the url I gave, you might try combining all the "bodies" together:

    .body ="Paragraph1" & vbcrlf & _
    "Paragraph 2" & vbcrlf & _
    "paragraph 3"


    Steve

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Body of Email using Excel (XP)

    A note in addition to Steve's excellent advice. You may need to examine and handle the format used on the message; plain text, RTF or HTML. From your question about placement of the workbook, I guess you are using RTF, but if you change default message format to HTML, you'll need to use the HTML paragraph character. Something like this will handle all three format options:

    Dim intEditorType As Integer
    intEditorType = ActiveInspector.EditorType
    OutMail.Body = "my first paragraph" & IIf(intEditorType = olEditorHTML, "", vbCrLf)
    OutMail.Body = OutMail.Body & "my second paragraph" & IIf(intEditorType = olEditorHTML, "", vbCrLf)
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Not in KC anymore
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Body of Email using Excel (XP)

    Thanks for the help. That did exactly what I needed.

    I added another "blank" paragraph to push the attachment down a line.

Posting Permissions

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