Having embedded an image in a HTML email, Outlook still shows it as an attachment. How do I stop that?

Posted on 2008-11-07
Last Modified: 2012-05-05
Using Delphi7 studio enterprise I am using COM automation to send emails via Outlook. When I use SMTP it is fine, but the embedded images in Outlook also appear as attachments which is untidy.

I have viewed the accepted solution for Q_21929137 and tried it but cannot get the variants fields to work.
Happy to provide code snippets and HTML source of emails, but the attaching of the signature images is as follows:
          for j := 0 to sl1.Count - 1 do
            strSourceFileName := sl1[j];
            strDisplayName := ExtractFileName(sl1[j]);
            // OlAttachmentType can be one of these OlAttachmentType constants.
            //   olByReference   = 4
            //   olByValue       = 1
            //   olEmbeddeditem  = 5
            //   olOLE           = 6

            intAttachType := 1;            
            intPosition := 1;
            oMailItem.MailItem.Attachments.Add(strSourceFileName, intAttachType, intPosition, strDisplayName);
Question by:futurelinksw
    LVL 36

    Expert Comment

    by:Geert Gruwez
    if these images are available on the internet/intranet
    and clients have internet/intranet access

    you could use the tag <img source=""/>

    no included images

    LVL 26

    Accepted Solution

    Well, The code below works for me and I have OL2007.
    Although after the display, I get a dialog that says "Incorrect Function"

    Give it a try and see what you think..

    procedure TForm1.Button1Click(Sender: TObject);
      objApp, l_Msg, oAttachs: OLEVariant;
      objApp := CreateOLEObject('Outlook.Application');
      l_Msg := objApp.CreateItem(olMailItem);
      oAttachs := l_Msg.Attachments;
      oAttachs.Add('c:\\feed-icon_orange-24px.bmp', olByValue, 1, 'MyImage');
      l_Msg.HTMLBody := '<IMG align="baseline" border="0" hspace="0" src="cid:feed-icon_orange-24px.bmp">';

    Open in new window


    Author Closing Comment

    No more answers forthcoming so accepting average solution.
    LVL 26

    Expert Comment

    Well, accepting ANY solution for an almost year old topic is the right thing.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now