+ Reply to Thread
Results 1 to 29 of 29

HTML email into strings for use in Outlook

  1. #1
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    HTML email into strings for use in Outlook

    Send Email.xlsm

    I need to set up my code to where it builds the entire html file. Once I have all my html in a string, lets call it strHTML…
    .HTMLBody = strHTML

    Do I need to keep the HTML tags.
    For example,

    Please Login or Register  to view this content.
    The formatting is really throwing me off for excel VBA strings in HTML. Set a reference to "Microsoft HTML object library" in the Developer in VBA.

    This is what is reading in Outlook:
    Dear Random people in company,
    If you would like the code. Email me.Unique IDProduct1Chips2Dip3Hummus4Pepsi5AquafinaThank you,Your Name

    Can someone please help me, so that this table and picture show up in the body of the email?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: HTML email into strings for use in Outlook

    Hello rmachbitz,

    If you intend to build an HTML how can you do it without using HTML tags?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    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
    43,970

    Re: HTML email into strings for use in Outlook

    You need pretty much all the HTML code you would have for a normal HTML Web Page.

    Please Login or Register  to view this content.

    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


  4. #4
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Arrow Re: HTML email into strings for use in Outlook

    I put that code in my ExportToHTML function. What else should I do with your code?? I am not getting a formatted HTML table.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Exclamation Re: HTML email into strings for use in Outlook

    PracticeEmail.xlsm

    I tried shortening my code to see what the problem was with the table. And even this code doesn't work.

    Please help with my VBA code to get the table and picture to send in Outlook using HTML!!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: HTML email into strings for use in Outlook

    Hello rmachbit,

    I found a macro I wrote by 2008 to convert a Range into HTML email it using Outlook. I tested it out to be sure it would work with 2010 - no problem. This will render the range as it is on the worksheet in HTML format. To view it in color, use Outlook. Other email client may not render the colors correctly or at all.

    Please Login or Register  to view this content.
    Exampple of Using the Macro
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Lightbulb Re: HTML email into strings for use in Outlook

    Dear Leith Ross,
    I put the code you posted into excel. Maybe it's my Outlook that's not reading the colors. What code should I change to get it to work in Outlook 2010?

    Please Login or Register  to view this content.
    This part of the code, I've never seen before. Can you explain this??

    PracticeEmail.xlsm

    Thank you!

  8. #8
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Post Re: HTML email into strings for use in Outlook

    PracticeEmail.xlsm
    GES logo.jpg

    I used this website to convert my .jpg to a string.
    http://www.askapache.com/online-tool...age-converter/

    Everything works now in Outlook 2010, except for the InsertPhoto() function.

    Please Login or Register  to view this content.
    Picture example img width =””176”” turns into width=”176”

    I call the function in the Sub EmailRangeInHTML(....)

    Please Login or Register  to view this content.
    What am I doing wrong?? I have attached the photo and the excel file. Thanks

  9. #9
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: HTML email into strings for use in Outlook

    With the string being in base64, it seems outlook won’t decode it properly…
    How would I convert a .jpg to MHT instead of HTML?

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

    Re: HTML email into strings for use in Outlook

    john55 explains how to embed an image in an email here.
    If posting code please use code tags, see here.

  11. #11
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: HTML email into strings for use in Outlook

    Right, but it still doesn't work for me. I posted on that forum too

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

    Re: HTML email into strings for use in Outlook

    Did you follow John55's directions?

  13. #13
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: HTML email into strings for use in Outlook

    Yes, you posted code that is .Attachments.Add which adds the attachment to the file, not the body of Outlook.
    I would like the .HTMLBody portion of the image to work.

    Please Login or Register  to view this content.

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

    Re: HTML email into strings for use in Outlook

    That's what I posted, not what John55 posted.

    His method doesn't involve attaching the file.

    If you want to try the method I suggested remove the path from src.
    Please Login or Register  to view this content.
    Last edited by Norie; 06-26-2013 at 12:14 PM.

  15. #15
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Arrow Re: HTML email into strings for use in Outlook

    emailCapture.PNG

    In my send folder, this is what I get when I do it your way (.png file)

    Please Login or Register  to view this content.
    I kept the .attachments.add part, just because I forgot to comment it out.

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

    Re: HTML email into strings for use in Outlook

    Why is there a space after cid:?

    Also, try sending the message.

  17. #17
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: HTML email into strings for use in Outlook

    Please Login or Register  to view this content.
    I removed the space after cid:

    I still don't see the image in the body of Outlook. Have you seen the excel file I've been working on?? It's called "PracticeEmail.xlsm" I've attached it in this forum.

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

    Re: HTML email into strings for use in Outlook

    Did you try actually sending the email?

    I just attached your picture and when I emailed it to my own google account I could see the image in the body.

    By the way, if this is a logo perhaps you should look into using a signature and adding it there.

  19. #19
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Post Re: HTML email into strings for use in Outlook

    PracticeEmail.xlsm

    I know how to add photos to my signature, that's not the problem. I pressed the button and the .Send was activated to send the email. I don't know if my code is in the wrong spot. I can upload my file again. Could you pinpoint what is wrong in the code? Also, is it something you Referenced in VBA, like a Microsoft library??

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

    Re: HTML email into strings for use in Outlook

    No specific library.

    The code in your workbook doesn't appear to have anything like this in it, and there's no image being attached.
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: HTML email into strings for use in Outlook

    Your code exactly matches my code. I don't see any difference.

  22. #22
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Re: HTML email into strings for use in Outlook

    What section of the code did you put that in? Is it Outlook 2010 specific?? Because that's what version of Outlook I have.

    Please Login or Register  to view this content.

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

    Can you post the exact code you now have?

  24. #24
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Post Re: HTML email into strings for use in Outlook

    PracticeEmail.xlsm

    Here is my current file. I hope this helps

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

    Re: HTML email into strings for use in Outlook

    Sorry, but I've already downloaded that file and it does't appear to have any code for adding an image.

    It has this but it does nothing.
    Please Login or Register  to view this content.
    Anyway, I amended the code and came up with this.
    Please Login or Register  to view this content.
    When I run that with my own gmail account as the recipient I see the logo in the received email.

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

    Re: HTML email into strings for use in Outlook

    Actually, I know why the code doesn't work with your image - it's the space in the name.

    If you rename the file to remove the space and adjust the code accordingly it definitely works.

    I thought it was working because gmail, for some reason, displays the image even if it's just an attachment.

    I'm sure there's a way to deal with the space but I haven't found anything so far.

  27. #27
    Forum Contributor
    Join Date
    06-20-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    106

    Thumbs up Re: HTML email into strings for use in Outlook

    It definitely works now! I just needed a space and I needed to make the name with underscores in it.

    Please Login or Register  to view this content.
    Thanks you for your persistence. I will mark this thread as solved!

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

    Re: HTML email into strings for use in Outlook

    You didn't need any extra spaces, you just needed to get rid of the space(s) in the filename.

  29. #29
    Registered User
    Join Date
    09-01-2015
    Location
    California
    MS-Off Ver
    2010
    Posts
    1

    Re: HTML email into strings for use in Outlook

    This code works great except for the fact that iPhone users cannot see these images. It just displays the image name. Does anyone know how to resolve this? I've tried both PNG and JPG.

+ 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