+ Reply to Thread
Results 1 to 4 of 4

Text Mail Body and HTML Body in same email

  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Text Mail Body and HTML Body in same email

    In the attached, I have a pivot table that I want to include in my email body. I have that part working perfectly.

    If I specify an HTML range to include in my email. I lose the text mail body.

    It is most likely that I would want to use both: an introductory line or two of text followed by the HTML content.

    I suspect that the answer lies in the RangetoHTML Code (which I did not write - I modified it from here: https://www.exceldemy.com/excel-vba-...to-email-body/). I tired "prepending" the text to the HTML code like this:
    Please Login or Register  to view this content.
    But that did not seem to work
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Text Mail Body and HTML Body in same email

    Your Mailer function is the problem. It is designed to accept a text body, and optionally a Range that will be converted to an HTML body. But if you give it a text body and set .body then also set .HTMLbody, .HTMLbody wipes out the text body.

    I have modified this function to be more robust, and your other code does not need to change.

    It now checks to see if an HTML range has been passed and if so, includes the text body as the first part of the HTML body.

    I have also changed the name of the argument HTMLBody to HTMLRange, since it is not an HTML body. I have also given it a default value of Nothing, since it's a Range.
    Attached Files Attached Files
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Text Mail Body and HTML Body in same email

    OK, that definitely does seem to work. Thanks mucho. Now I can have fun taking it apart to see how you did it .

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Text Mail Body and HTML Body in same email

    I see what you did. The declaration and assignment to Nothing makes sense.

    OK, I just made my "Swiss Army Knife Mailer" a bit more flexible.

+ 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. Retain the text format for a Email Body while sending mail with VBA
    By Ravisca2003 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-05-2017, 11:47 AM
  2. Getting html code instead of output in mail body
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-15-2016, 09:42 PM
  3. [SOLVED] specific colour of text and font in email body- need HTML tags
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-18-2015, 05:10 AM
  4. Using HTML Body Format in Outlook mail
    By akash kothari in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2014, 11:33 AM
  5. Copy and paste text and a chart into Html Email body
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2014, 09:22 AM
  6. Send e-mail with image on body (.html) on e-mail manager <> outlook
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 09:28 PM
  7. Encode Text Of Body Of Email Into HTML
    By WJO in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2012, 02:27 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