+ Reply to Thread
Results 1 to 14 of 14

Adding a Range to an Email Body

  1. #1
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Adding a Range to an Email Body

    Good afternoon,

    I'm trying to add a range to this email code that will then paste the information into the body of this email however instead of getting the data I need i'm getting "-1" in the body instead.

    I've tried defining the range below and adding that line to the main code but it doesn't work, the code will run but i get "-1" in the body.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Adding a Range to an Email Body

    Try without the select at the end.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Adding a Range to an Email Body

    You need to use RonDebruins RangetoHTML method..
    http://www.rondebruin.nl/win/s1/outlook/bmail2.htm

    or.. if your range is contiguous..

    Try snb's method (much less code)
    http://www.snb-vba.eu/VBA_Excelgegev...len_en.html#L4

  4. #4
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Adding a Range to an Email Body

    Would RonDeBrins method attach the workbook and paste a range into the body or just paste everything into the body? As i need it to attach the work book and take some data and paste that into the body of the message.

    Nathansav - Thanks for the help but that didn't work.
    Last edited by djfatboyfats; 08-13-2014 at 07:23 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Adding a Range to an Email Body

    As the name suggests.. it will convert a range to html and allow that to be used in the .HTMLBody of the email..

    The link i gave has a pretty good example..

    I personally prefer snb's method.. much less code.. and you can make it work on non contiguous ranges by filtering/copying the data to a temp sheet to make it a contiguous range..

  6. #6
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Adding a Range to an Email Body

    Cheers Apo. So as far as you know there isn't any way to send the workbook as an attachment AND copy a range of data into the body of the email? It has to be one or the other, either an attachement or HTML in the body.

    Regards

    DJ

  7. #7
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Adding a Range to an Email Body

    Hi..

    Sorry.. i must have misunderstood your question.. yes.. you can send the Workbook as an attachment and also insert a range into the .htmlbody of the email..

    I don't think one negates the other...

    Again.. I refer to my bible:

    http://www.snb-vba.eu/VBA_Excelgegev...len_en.html#H3

  8. #8
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Adding a Range to an Email Body

    I cant get this to work, could someone be kind enough to send the code or a sample workbook that will send the file as an attachment and place a range into the body of an email?. I would be truly grateful

    Thanks

    DJ

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Adding a Range to an Email Body

    What have you tried?
    If posting code please use code tags, see here.

  10. #10
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Adding a Range to an Email Body

    I've been looking at RonDeBruin's website any trying numerous different codes, I can get an email to send in the HTML body and I can get an attachment in the email but I cant do both. I have also looked at
    HTML Code: 
    but still the same. I've also tried adding ranges to the Body part of the code but nothing is working.

    Thanks in advance

    DJ

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Adding a Range to an Email Body

    This will add a range to the body and add the activeworkbook as an attachment.
    Please Login or Register  to view this content.
    Note, this is basically the snb's code from the link apo provided, the only thing I added was the attachment part.

  12. #12
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Adding a Range to an Email Body

    Thanks very much. Do you know if there is a way to keep the formatting in the HTML body? When it copy's the range into the email it loses all the colour and it has some kind of grid line around it.

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Adding a Range to an Email Body

    You would need Ron de Bruin's code for that.

  14. #14
    Forum Contributor
    Join Date
    08-24-2006
    Location
    Sevenoaks, Kent
    MS-Off Ver
    Office 365 ProPlus
    Posts
    459

    Re: Adding a Range to an Email Body

    OK, Thank you very much for your help so far, its appreciated. I will have a look at Ron's website and see if I can figure it out.

    Regards

    DJ

+ 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. [SOLVED] sending email with specific range as email body vba modification
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2014, 11:24 AM
  2. 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
  3. Adding to body in email
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-24-2013, 03:09 PM
  4. Adding body to email via VBA for an outlook template
    By teekayy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-09-2012, 04:19 AM
  5. [SOLVED] Adding a disclaimer changes image in email body
    By johncassell in forum Outlook Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2012, 08:42 AM

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