+ Reply to Thread
Results 1 to 7 of 7

Sent Email shows up with blank body

  1. #1
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    204

    Sent Email shows up with blank body

    Dear mr/mrs,

    Below VBA is working on outlook 2016,
    can somebody help me why the body is blank?
    I don't understand this problem, so I am looking for some help.
    Thank you in advance for your support

    Dim strbody As String
    Dim oApp As Object
    Dim oMail As Object
    Dim WB As Workbook
    Dim FileName As String
    Dim wSht As Worksheet
    Dim shtName As String
    Dim ThisFile As String
    Dim oByValue


    ThisFile = "C:\test\Test1.xlsx"
    Application.ScreenUpdating = False

    'Create and show the Outlook mail item
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItem(0)

    With oMail


    .To = Sheets("Sheet1").Range("B1").Value
    .Subject = Sheets("Sheet1").Range("B2").Value


    With ThisWorkbook.Sheets("Sheet1")
    strbody = "Dear mrs Rania," & vbNewLine & vbNewLine & _
    .Range("B3") & vbNewLine & _
    .Range("B4") & vbNewLine & _
    .Range("B5") & vbNewLine & _
    .Range("B6") & vbNewLine & _
    .Range("B7") & vbNewLine & _
    .Range("B8") & vbNewLine & _
    .Range("B9")
    End With
    .Attachments.Add ThisFile
    .Attachments.Add "C:\test\Test1.xlsx", oByValue, 0

    .Display
    End With

    'Restore screen updating and release Outlook
    Application.ScreenUpdating = True
    Set oMail = Nothing
    Set oApp = Nothing
    End Sub[/CODE]
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by kirana2014; 09-08-2017 at 10:09 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Sent Email shows up with blank body

    You haven't told it what to use as the body.....
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    204

    Re: Sent Email shows up with blank body

    Please help how !

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Sent Email shows up with blank body

    I did! You are missing that line of code I gave you...

  5. #5
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    204

    Re: Sent Email shows up with blank body

    I try :

    .To = Sheets("Sheet1").Range("B1").Value
    .Subject = Sheets("Sheet1").Range("B2").Value
    .body = strbody

    Please help

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Sent Email shows up with blank body

    The code runs in order line by line, you can't place
    Please Login or Register  to view this content.
    before
    Please Login or Register  to view this content.
    How is the code supposed to know what strbody is before you have indicated what strbody is?


    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    204

    Re: Sent Email shows up with blank body

    Thank you for your time and help ( is working )

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to send email from excel using VBA with Cell Range (Including Images) as Email Body
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2014, 05:06 AM
  2. vba pull data from outlook body of email through email or subject of mail into excel
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2014, 04:37 AM
  3. [SOLVED] Skipping Blank Cells in a HTML Email Body
    By bocaj315 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2013, 04:03 PM
  4. Send New Email W/ Body of Received Email, Then Delete Sent Email
    By edneal2 in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 07-01-2013, 12:45 AM
  5. Skipping blank cells in Email body
    By bocaj315 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-21-2013, 12:19 PM
  6. Replies: 5
    Last Post: 06-09-2013, 12:27 PM
  7. Replies: 6
    Last Post: 12-02-2011, 02:14 PM
  8. Replies: 0
    Last Post: 04-07-2009, 04:42 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1