+ Reply to Thread
Results 1 to 9 of 9

How to insert an image into a HTML E-Mail body?

  1. #1
    Registered User
    Join Date
    07-15-2017
    Location
    Switzerland
    MS-Off Ver
    MS 10
    Posts
    16

    How to insert an image into a HTML E-Mail body?

    hi all,

    Does anyone has a solution on how to insert an image into an HTML E-Mail body with a Macro when the files name was previously defined?
    The Filename was defined as follow and stored in a local folder.
    Filename = Range("C49").Value

    The idea is to create Factsheets and each has a different name. Therefore the HTML Code has to be flexible.

    I'm using this code for this step:

    With OLmail
    .to = " "
    .cc = " "
    .BCC = " "
    .Subject = " "
    .attachments.Add "N:\" & Filename & ".emf", 0
    'here you can ajust the picture size in the mailbody (width and heigt)
    .htmlbody = .htmlbody & "<img src='cid:Filename.emf'" & "width='1000' heigt='4000'><br>"
    .Display
    End With


    Thanks for your response

    Flo

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

    Re: How to insert an image into a HTML E-Mail body?

    Flo

    You would need to have the actual value of Filename in the HTML.

    Try this.
    Please Login or Register  to view this content.
    PS When posting code can you please use CODE tags?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-15-2017
    Location
    Switzerland
    MS-Off Ver
    MS 10
    Posts
    16

    Re: How to insert an image into a HTML E-Mail body?

    Hi Norie,

    Thanks for the quick response. Sadly it does not work properly... When the E-Mail is created it states that "the linked image cannot be display" and the image is in the attachment and not in the body.
    However, when I take an actual file with the name "1" for example the attachmet is properly hidden and the image visible in the body. Is there an other way around to leave the file connection flexible?

    Sorry will use code tags in the future.

    Best,
    Flo

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

    Re: How to insert an image into a HTML E-Mail body?

    Flo

    When you try it with an actual filename is that file an emf file?

  5. #5
    Registered User
    Join Date
    07-15-2017
    Location
    Switzerland
    MS-Off Ver
    MS 10
    Posts
    16

    Re: How to insert an image into a HTML E-Mail body?

    Yes it is the same file that I just renamed for this test purpose.

    I tied it aswell as .gif/.png/.jpg but it didn't work...

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

    Re: How to insert an image into a HTML E-Mail body?

    What is the value of Filename when things don't work?

  7. #7
    Registered User
    Join Date
    07-15-2017
    Location
    Switzerland
    MS-Off Ver
    MS 10
    Posts
    16

    Re: How to insert an image into a HTML E-Mail body?

    I don't see a value. How can I look this up? and Filename is defined as string. Could this might cause the problem?

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

    Re: How to insert an image into a HTML E-Mail body?

    The value of the variable Filename is set here.
    Please Login or Register  to view this content.
    Does C49 have a valid path and filename to the image you are trying to show in the email?

  9. #9
    Registered User
    Join Date
    07-15-2017
    Location
    Switzerland
    MS-Off Ver
    MS 10
    Posts
    16

    Re: How to insert an image into a HTML E-Mail body?

    C49 should be the name of the image. However, it was probably to compilcated with multiple & and _ in it. I've found a solution that works.
    Thanks a lot for your help and have a good evening.

    Greetings,
    Flo

+ 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. 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
  2. Insert hyperlink in an e-mail body
    By leandro.fernandez in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2015, 10:50 PM
  3. 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
  4. sending mail in outlook with image in Top center of body .
    By yogananda.muthaiah in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-25-2012, 05:06 PM
  5. Help needed to insert the Image on Body of the mail
    By gvreddyhr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2012, 04:30 PM
  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. Send E-mail with image in e-mail body
    By ncaravela in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2010, 10:54 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