Insert image in Outlook with advanced mapi features

I need to embed images in email and view email before sending it to Outlook. CDO and Redemption are not an option.

I tried the following code, but the images just display as a small block.

  procedure AddAttachment(FullFileName: String; Attachments: Outlook2000.Attachments; CID: String);
  const
    PR_ATTACH_CONTENT_ID   = $3712001E;
    PR_ATTACH_CONTENT_ID_W = $3712001F; // Unicode
    PR_ATTACH_MIME_TAG     = $370E001E;
    PR_ATTACH_ENCODING     = $37020102;
  var
    IAttach: IMAPIProp;
    Prop: PSPropValue;
    AAttachment: Outlook2000.Attachment;
    FileName: String;
    PropValue: TSPropValue;
    Prop1: TSPropTagArray;
  begin
    FileName := ExtractFileName(FullFileName);
    Prop := nil;
    try
      AAttachment := Attachments.Add(FullFileName, olByValue, 1, FileName);
      IAttach := AAttachment.MAPIOBJECT as IMAPIProp;
      if Assigned(IAttach) then
        try
          PropValue.ulPropTag := PR_ATTACH_MIME_TAG;
          PropValue.Value.lpszA := 'image/jpeg';
          HrSetOneProp(IAttach, @PropValue);
          PropValue.ulPropTag := PR_ATTACH_CONTENT_ID;
          PropValue.Value.lpszA := PAnsiChar(AnsiString(CID));
          HrSetOneProp(IAttach, @PropValue);
        finally
          if Assigned(Prop) then MAPIFreeBuffer(Prop);
          IAttach := nil;
        end;
    except
    end;
  end;
+5
source share
1 answer

The participant has not posted their HTML text. I suspect the problem is that its CID URLs were garbled - I never tested this.

If the Content-ID header is set to this:

Content-Type: image/jpeg
Content-Disposition: inline
Content-ID: afd383988e86ad958709@u

Then the HTML should reference it like this:

<img width="100" height="100" href="cid:afd383988e86ad958709@u" />

, URL- cid "cid:", . (A guid - , , @. , "@u" guid.)

, . Outlook , .

:

+1

All Articles