tags:

views:

55

answers:

0

I need to embed images in an email and preview the email before it is sent in outlook. CDO and Redemption is not an option.

I have tried the following code, but the images just appears as a little 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;