Re: problem with body in outlook

Giganews Newsgroups
Subject: Re: problem with body in outlook
Posted by:  Tomas (tom…@gmail.com)
Date: Wed, 23 Apr 2008

While reading
http://www.indyproject.org:80/Sockets/Blogs/RLebeau/2005_08_17_A.EN.aspx
I have found solution, not sure is this correct, can anyone confirm what
code looks correct?

I have added

        with TIdText.Create(IdMsg.MessageParts, nil) do begin
          ContentType := 'multipart/alternative';
        end;

before building message and also set

ParentPart := 0;

in TIdText.Create while building html body.

  IdMsg.IsEncoded := True;
        IdMsg.CharSet := 'iso-8859-1';
        IdMsg.Encoding := meMIME;
        IdMsg.Recipients.EMailAddresses := ToAddress.Text;
        IdMsg.BccList.EMailAddresses := BCC.Text;
        IdMsg.Subject := Subject;
        IdMsg.From.Address := FromAddress;
        IdMsg.From.Name := FromName;
        IdMsg.ReplyTo.EMailAddresses := ReplyTo;
        IdMsg.ContentType := 'multipart/*';

        Body.text :='my <b>body</b>';

        with TIdText.Create(IdMsg.MessageParts, nil) do begin
          ContentType := 'multipart/alternative';
        end;

        with TIdText.Create(IdMsg.MessageParts, Body) do
        begin
            ParentPart := 0;
            ContentType := 'text/html';
        end;

        FFileName:='c:\1.pdf'

          with TIdAttachmentFile.Create(IdMsg.MessageParts, FFileName) do
          begin
            ContentType := GetMimeTypeFromFile(FFileName);
            FileName := ExtractFileName(FFileName);
          end;

"Tomas" <tom…@gmail.com> wrote in message
news:BF82341B2E51E340tom…@gmail.com...
> Hello,
>
> I use code below to create html e-mail with attachment. Everyhting works
> fine on most of e-meilers, but
> on Outlook Express I get two attachments and no html body. I see body html
> as attachment and it is not displayed in outlook viewer.
>
> Maybe someone could help me?
>
> Regards,
> Tomas
>
>        IdMsg.IsEncoded := True;
>        IdMsg.CharSet := 'iso-8859-1';
>        IdMsg.Encoding := meMIME;
>        IdMsg.Recipients.EMailAddresses := ToAddress.Text;
>        IdMsg.BccList.EMailAddresses := BCC.Text;
>        IdMsg.Subject := Subject;
>        IdMsg.From.Address := FromAddress;
>        IdMsg.From.Name := FromName;
>        IdMsg.ReplyTo.EMailAddresses := ReplyTo;
>        IdMsg.ContentType := 'multipart/*';
>
>        Body:='my <b>body</b>';
>
>        with TIdText.Create(IdMsg.MessageParts, Body) do
>        begin
>            ContentType := 'text/html';
>        end;
>
>        FFileName:='c:\1.pdf'
>
>          with TIdAttachmentFile.Create(IdMsg.MessageParts, FFileName) do
>          begin
>            ContentType := GetMimeTypeFromFile(FFileName);
>            FileName := ExtractFileName(FFileName);
>          end;

Replies

In response to

problem with body in outlook posted by Tomas on Wed, 23 Apr 2008