[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3026
  • Last Modified:

Why are the embedded image in HTML email not displayed in OUTLOOK 2010?

Hi All,
I created HTML email template and sent email to OUTLOOK 2010. But I found the embedded images were not displayed. They are displayed as squares with red cross.

HTML Template:

        text-align: center;

    <table class="" cellpadding="0" cellspacing="0" border="0" width="752">    
          <td class="border"><img alt="" src="images/header.jpg" /><br /><br /></td>
          <td class="border"><br /><img alt="" src="images/footer.jpg"
                  style="width: 961px" /></td>

var message = new MailMessage
                                        From = new MailAddress(mail.From),
                                        To = new MailAddress(mail.To),
                                        Subject = mail.Subject,
                                        Body = mail.Body,
                                        IsBodyHtml = true,
                                        BodyEncoding = Encoding.UTF8,
                                        SubjectEncoding = Encoding.UTF8,

var client = new SmtpClient();

I tried the following solutions but none is working:
1. Unblock picture downloads for all messages

    On the Tools menu, click Trust Center, and then click Automatic Download.
    Clear the Don't download pictures automatically in HTML e-mail messages or RSS items check box.

2. clear the SecureTemp folder and delete the contents

3. untick the 'show picture placeholder' on outlook2010

Does anyone know what is going on?

thanks heaps
3 Solutions
In your email body you have not specified the correct source for the image.

The line:

<img alt="" src="images/footer.jpg">

Should have the complete URL to find the image. By way of example if your website is "www.yourdomain.com" then the line would be:

<img alt="" src="http://www.yourdomain.com/images/footer.jpg">

Then when the email is viewed the image is downloaded from your website.

On the other hand, if you are including the email as "inline-attachments" in a multi-part email message, the image source would need to reflect that.
viola123Author Commented:
thanks a lot, i will try to put my images under our website folder.
i will let you know the result.
Alan WarrenCommented:
Hi viola123,
you'd stand a better chance of the image being displayed if it was embedded as an attachment to the mail message.

LinkedResource Class
Represents an embedded external resource in an email attachment, such as an image in an HTML attachment.

Asp .Net VB sample sending email with linked resources embedded in html:
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  Protected Sub ButtonSendCoolPic_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonSendCoolPic.Click
    ' we won't be needing this, maybe...
    Dim strError As String = ""
    ' Populate the smtp server name
    Dim strSmtpMailServer As String = "smtp.some.com"
    ' Populate the smtp user name credential
    Dim strSmtpUsername As String = "validmailuser@some.com"
    ' Populate the smtp password credential
    Dim strSmtpPassword As String = "validmailuserpassword"
    ' Create the NetworkCredential object
    Dim objNetworkCredential As New System.Net.NetworkCredential(strSmtpUsername, strSmtpPassword)

    ' Create the SmtpClient object
    Dim objSmtpClient As New System.Net.Mail.SmtpClient(strSmtpMailServer)

    ' Parse the NetworkCredential to the smtpclient object
    objSmtpClient.Credentials = objNetworkCredential
    Dim objMailMessage As System.Net.Mail.MailMessage = Nothing
    ' http://msdn.microsoft.com/en-us/library/ms144655
    ' Represents an embedded external resource in an email attachment, such as an image in an HTML attachment.
    Dim objLinkedResource1 As System.Net.Mail.LinkedResource = Nothing
    Dim objHTLMAltView As System.Net.Mail.AlternateView = Nothing

    ' Usual stuff
    Dim strRecipientName As String = "Some Recipient"
    Dim strRecipientEmail As String = "somerecipient@gmail.com.net.org.edu"
    Dim strSenderName As String = "Me"
    Dim strFrom As String = "me@some.com"
    Dim strSubject As String = "Cool Pic!"
    ' the html body
    Dim strBody_Html As String = ""
    ' the physical path to the image
    Dim strLinkedResource1PhysicalPath As String = Server.MapPath("~/") & "pics\cool-pic.jpg"
    ' Construct the alternate body as HTML.
    strBody_Html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" + vbLf
    strBody_Html += "<html xmlns='http://www.w3.org/1999/xhtml'>" + vbLf
    strBody_Html += "  <head>" + vbLf
    strBody_Html += "    <title></title>" + vbLf
    strBody_Html += "  </head>" + vbLf
    strBody_Html += "  <body>" + vbLf
    strBody_Html += "    <div>" + vbLf
    strBody_Html += "      <table>" + vbLf
    strBody_Html += "          <tr>" + vbLf
    strBody_Html += "            <td>" + vbLf
    strBody_Html += "              <h3>Hi " & strRecipientName & ",</h3>Check this cool pic!" + vbLf
    ' populate the src of the image with the linkedresource.cid 
    strBody_Html += "              <img src='cid:cool_pic'  />" + vbLf
    strBody_Html += "            </td>" + vbLf
    strBody_Html += "          </tr>" + vbLf
    strBody_Html += "      </table>" + vbLf
    strBody_Html += "    </div>" + vbLf
    strBody_Html += "  </body>" + vbLf
    strBody_Html += "</html>" + vbLf


      ' Create a message and set up the recipients.
      objMailMessage = New System.Net.Mail.MailMessage()

      ' Populate the From line of the mail message
      objMailMessage.From = New System.Net.Mail.MailAddress(strFrom)

      ' Populate the subject line of the mail message
      objMailMessage.Subject = strSubject

      objLinkedResource1 = New System.Net.Mail.LinkedResource(strLinkedResource1PhysicalPath, "image/jpeg")
      ' create a handle that we can reference in the src property of the embedded image
      objLinkedResource1.ContentId = "cool_pic"

      ' Add the linked resource/s to the AlternateView.
      objHTLMAltView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(strBody_Html, New System.Net.Mime.ContentType("text/html"))

      ' Add the alternate view to the message.

      ' Set the Priority property of the mail message [Low=0,Normal=1,High=2]
      objMailMessage.Priority = System.Net.Mail.MailPriority.Normal

      ' Send the message.

    Catch ex As Exception
      ' parse the error and return it to the calling procedure
      strError = ex.Message

    End Try

  End Sub


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <form id="form1" runat="server">
      <asp:Button runat="server" Text="Send Cool Pic" ID="ButtonSendCoolPic" />

Open in new window

viola123Author Commented:
Hi Alan,
thanks for reply, i will try this one as well.

thanks heaps
If you are using a custom Template/Form
Depending on who you are sending it to
You may need to make sure the Recipients got a local copy saved in their Forms LIbaray
Otherwise it going to get to the recipient and outlooks not going to have the information to interpret it

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now