+ Reply to Thread
Results 1 to 7 of 7

Outlook Embedded Image - Red x

Hybrid View

  1. #1
    Registered User
    Join Date
    01-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    15

    Outlook Embedded Image - Red x

    This code works perfectly on my home PC... however when I try and run it on my work PC the image comes up with the red cross box implying it is unable to locate the image location. However, the file exists as I can navigate to it by copying and pasting the code to the picture...

    I thought it may be because the image was on the network... have changed to local, though still no joy.

    Driving my crazy...! Any ideas?

    Sub EmailImage()
        Dim OL As Object, rng As Range
        Dim EmailItem As Object
        Application.ScreenUpdating = False
        Set OL = CreateObject("Outlook.Application")
         
        Set EmailItem = OL.CreateItem(0)
        
        With EmailItem
            .HTMLBody = "<html><p>This is a picture.</p>" & _
                "<img src=C:\Images\EMailImage.png' >"
            .To = EmailTo
            .CC = ""
            .BCC = YouWillNeverKnow
            .Subject = "*** UPDATE *** @ " & Format(Sheets("HelpMe").Range("K13"), "hh:mm")
            .Display   'or use .Display (.Send to send)
        End With
    
    End Sub

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

    Re: Outlook Embedded Image - Red x

    Hi..

    I am pretty sure you need to also add the image as an attachment for it to display in the html body..

    Try adding this:
    .Attachments.Add ("C:\Images\EMailImage.png")
    The image won't show when youpreview the email being sent.. but it WILL show when the receiver views the email... try sending it to yourself to check..

  3. #3
    Registered User
    Join Date
    01-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Outlook Embedded Image - Red x

    Thanks for the reply.

    This code adds the image as an attachment, which can be previewed in the e-mail before sending. This at least confirms that my image exists and the path is correct, but I want to embed the image into the e-mail so it is immediately viewed when received rather than have it as an attachment.

    Also, the code works accurately on my PC but not my work one suggesting it may be a setting that needs to be tweaked?

  4. #4
    Registered User
    Join Date
    01-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Outlook Embedded Image - Red x

    I have Office 2010 at home yet 2007 at work... does anyone think that this could be a compatibility issue?

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

    Re: Outlook Embedded Image - Red x

    Hi..

    Try testing the Workbook attached..

    To test.. add your email address in the Yellow cell (B2)..

    Select some of the numbers below if you want to see them included in the email body..

    More to the point.. add an image at/named: c:\image1.png on your PC

    Click the button and send the email..

    In the email that you receive...

    You should see the image embedded at the bottom of the email..

    This workbook works for me.. should work on 2007 also..

    Lemme know how you go with it..

  6. #6
    Registered User
    Join Date
    01-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Outlook Embedded Image - Red x

    Still doesn't like it... adds it as an attachment with the below text where the image is meant to appear:

    < img src='c:\image1.png'>

    This is after sending the e-mail.

  7. #7
    Registered User
    Join Date
    01-23-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Outlook Embedded Image - Red x

    Ok, I've managed to work out what the problem was with my original code... it would appear that if you have spaces in any of the image directories then it can not locate the file.

    There is probably an HTML reason why this is the case, though I have limited understanding of HTML and so don't know why. Anyway, the below code works well and I think is quite simple... hopefully it will be of help of somebody out here but just remember NO SPACES IN DIRECTORIES!!!

    Sub EmailImage()
        Dim OL As Object, rng As Range
        Dim EmailItem As Object
        Application.ScreenUpdating = False
        Set OL = CreateObject("Outlook.Application")
         
        Set EmailItem = OL.CreateItem(0)
        
        With EmailItem
            .HTMLBody = "<html><p>This is a picture.</p>" & _
                "<img src=C:\Adrian\Image1.png' >"
            .To = EmailTo
            .CC = ""
            .BCC = YouWillNeverKnow
            .Subject = "*** UPDATE *** @ " & Format(Sheets("Sheet1").Range("K13"), "hh:mm")
            .Display   'or use .Display (.Send to send)
        End With
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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