Re: HTML email - views fine in Outlook, wrong in GMail and other webmail viewers

Giganews Newsgroups
Subject: Re: HTML email - views fine in Outlook, wrong in GMail and other webmail viewers
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Tue, 9 Oct 2007

"Jonathan Hyams" <jhya…@btopenworld.com> wrote in message
news:724F08FB9338E340jhya…@btopenworld.com...

> Here's my code:

You did not include a "plain/text" part.  Some readers require that in order
for HTML to work correctly.  Try this instead:

    var
        Folder: String
    begin
        Folder := ExtractFilePath(Application.ExeName);

        //...

        MyMessage.IsEncoded := True ;
        MyMessage.ContentType := 'multipart/alternative';
        MyMessage.ClearBody;

        with TIdText.Create(MyMessage.MessageParts, nil) do
        begin
            Body.Text := 'Your reader does not support HTML';
            ContentType := 'text/plain';
        end;

        with TIdText.Create(myMessage.MessageParts, nil) do
        begin
            ContentType := 'multipart/related; type="text/html"';
        end;

        with TIdText.Create(myMessage.MessageParts, nil) do
        begin
            Body.LoadFromFile(Folder + 'htmlmail.htm');
            ContentType := 'text/html';
            ParentPart := 1;
        end;

        with TIdAttachmentFile.Create(myMessage.MessageParts, Folder +
'image001.jpg') do
        begin
            ContentID := '10001';
            ContentType := 'image/jpeg';
            ContentDisposition := 'inline';
            ParentPart := 1;
        end;

        //...
    end;

Gambit

Replies

In response to

HTML email - views fine in Outlook, wrong in GMail and other webmail viewers posted by Jonathan Hyams on Tue, 9 Oct 2007