+ Reply to Thread
Results 1 to 10 of 10

Copy from Excel to Outlook as HTML

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    mandya
    MS-Off Ver
    Excel 2010
    Posts
    6

    Copy from Excel to Outlook as HTML

    Hi All,

    My workbook has 5 different sheets and I need to copy the five sheets and paste it into 5 different mails. Preferably as HTML.

    The below written code only attaches the different sheets to outlook. I need the HTML below the body of the email. Please note that my range in the sheets varies from workbook to workbook but the sheet names remain the same.

    Please Login or Register  to view this content.

    The below written code just copies the sheets to outlook as HTML but doesn't attach the files


    Please Login or Register  to view this content.

    How do I merge both the codes?

    Here;s the sample file
    https://skydrive.live.com/redir?resi...LXmsEmw9mB3qlk

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Copy from Excel to Outlook as HTML

    I'm not entirely sure what you want/need to do.

    The basic structure to send an email, use:

    Please Login or Register  to view this content.

    Your code saves a page as HTML and then reads it back in ... so far so good.


    If you want to see the HTML code rather than how it is rendered, you'd use .Body instead of .htmlBody (as above)

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-03-2012
    Location
    mandya
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy from Excel to Outlook as HTML

    What I want to do is that I want to copy each sheet to different mails. Also attach the relevant sheet to the mail

  4. #4
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Copy from Excel to Outlook as HTML

    Hi -

    You can alter the second code you have to something like;
    Please Login or Register  to view this content.
    Regards,
    Event

  5. #5
    Registered User
    Join Date
    12-03-2012
    Location
    mandya
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy from Excel to Outlook as HTML

    Your code works like a charm!! Thank YOU!!
    How do I hard code the different email addresses into the macro

  6. #6
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Copy from Excel to Outlook as HTML

    Hi -

    Please Login or Register  to view this content.
    Regards,
    Event

  7. #7
    Registered User
    Join Date
    12-03-2012
    Location
    mandya
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy from Excel to Outlook as HTML

    I'm getting a run time error 9

    Subscript out of range

    Sheets(oneSheet.Name).Copy in this line.

    Cant really figure out whats wrong

  8. #8
    Registered User
    Join Date
    12-03-2012
    Location
    mandya
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy from Excel to Outlook as HTML

    Quote Originally Posted by event21 View Post
    Hi -

    Please Login or Register  to view this content.
    Regards,
    Event
    This code will work if the email address is same for all the sheets. But in my case I need to send the mails to different addresses

  9. #9
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Copy from Excel to Outlook as HTML

    Hi -

    Have one sheet to store your email addresses with corresponding sheet name and look up the sheet name within the loop then pass it onto the To fields.

    Regards,
    Event

  10. #10
    Registered User
    Join Date
    12-03-2012
    Location
    mandya
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy from Excel to Outlook as HTML

    Quote Originally Posted by event21 View Post
    Hi -

    You can alter the second code you have to something like;
    Please Login or Register  to view this content.
    Regards,
    Event
    I''ve modified the code to add a subject but it doesn't work
    I'm getting a run time error 9
    Subscript out of range

    Sheets(oneSheet.Name).Copy (IN THIS LINE)

    Can any one help.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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