+ Reply to Thread
Results 1 to 16 of 16

HTML email from Excel

  1. #1
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    HTML email from Excel

    Hi all

    I've created an Excel macro that sends out emails with different parts depending on who the email is going to (puts persons name, username and few other things into the email) just fine on 2007.
    I've now got 2013, and part of the company audit has been to improve my department.
    One part of this is to now send out these emails with two images in HTML format.

    I keep getting the same 'run time error: 438; object doesnt support method or property' on the first .Attatchments.Add "G"\... part

    Any assistance would be great please (: I would upload the whole file but there's more than 1 macro and alot of personal information to remove.

    Please Login or Register  to view this content.
    Last edited by Aaron092; 06-16-2014 at 04:13 AM. Reason: Resolved

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: HTML email from Excel

    Have you tried commenting it out?

    Have you tried adding the path to the graphic?
    Please Login or Register  to view this content.
    Last edited by Tinbendr; 06-13-2014 at 08:16 AM.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    Hi Tinbender

    Sorry, I've deleted too much of the file locations.

    The files are images; small logos, which are above and below the body text. (two different ones)
    I've tried commenting it out, and it gives error 5 or 9, but the stupid thing is, the original macro that I've based this on works fine
    found here: vba-useful.blogspot.co.uk/2014/01/send-html-email-with-embedded-images.html

    I can clear some details out of the file and attach it if that helps?

    Thanks

  4. #4
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    If you, Tinbender, or anyone else would like to look at the file, I have attached a copy to this post.

    Thank you
    Attached Files Attached Files

  5. #5
    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 from Excel

    Isnt' Attachments spelt Attachments, not Attatchments?

    PS When embedding images in an email you don't use the path to the source file for the src attribute of the img element, you use cid:filenameofimage.

    For example this embeds the image named DashBoardFile.jpg.
    HTML Code: 
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    Hi Norie

    Yes, you are absolutely right. It's now sending but only the last image is showing, and the body text is just two zeros ("00") after this image

  7. #7
    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 from Excel

    I think you might need to check your HTML code.

    By the way, what are you doing here?
    Please Login or Register  to view this content.
    Why would you be concatenating the HTMLBody to itself?

  8. #8
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    I will do when I get home this evening. Also, this is the first time I've had to use HTML in VB.

    The first part of that is the image, then sizing the image to a rectangle and the original code I used finished with that <br></FONT></SPAN> and the little bit of HTML I do know, I thought that bit ended it.

  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: HTML email from Excel

    Actually just noticed another thing, this should not be in the midst of the HTMLBody section of the code,
    Please Login or Register  to view this content.
    attach the images after the setting the subject, and then do the HTMLBody part.

    PS If I go through the code this is what the HTML ends up as,
    HTML Code: 
    which might explain what you are seeing.

  10. #10
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    I've moved the attachments to after .Subject, and removed the last part too.
    I've removed the images, I've taken parts out I don't need right now.. I still get the double zeros when the email comes through.

  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: HTML email from Excel

    Can you post the current code?

  12. #12
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    Please Login or Register  to view this content.

  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: HTML email from Excel

    You definitely need to get rid of this.
    Please Login or Register  to view this content.
    This should probably just be "<br>".
    Please Login or Register  to view this content.
    By the way, you seem to be doubling up quotes quite a bit in the HTML and as far as I can see that's not needed.

    Perhaps something like this would work.
    Please Login or Register  to view this content.
    PS I include a variable, Pwd for the password.
    Last edited by Norie; 06-13-2014 at 11:58 AM.

  14. #14
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    Can't get rid of the < br > "" part as it gives an expected expression error.
    For that main body part, now down to this, sends just fine, returns one zero now. Better than two, I guess :P

    Please Login or Register  to view this content.

  15. #15
    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 from Excel

    Did you try what I added to post #13?

  16. #16
    Forum Contributor
    Join Date
    01-30-2014
    Location
    England
    MS-Off Ver
    MS Office 2010, 2007, 2003
    Posts
    149

    Re: HTML email from Excel

    Norie, you are a star. It's sending the text in the right format which is close enough!
    I'll be able to get the images in, but thank you so much for your patience and help.
    Much appreciated.

+ 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 parse data in Outlook email using HTML version of email back to excel
    By bnasty in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-31-2012, 02:54 PM
  2. Sending HTML email via excel VBA - arriving as RTF email
    By Shuter1 in forum Outlook Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2012, 04:35 AM
  3. Automate Lotus Notes email with HTML body from excel
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2010, 06:47 PM
  4. Excel macro to send HTML Body email
    By Benjamin2008 in forum Excel General
    Replies: 1
    Last Post: 05-01-2010, 05:29 AM
  5. HTML,Excel, Email
    By gad110 in forum Excel General
    Replies: 0
    Last Post: 08-03-2007, 12:04 PM

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