multipart/alternate clarification

Giganews Newsgroups
Subject: multipart/alternate clarification
Posted by:  Frank Bishop (francis12…@fairpoint.net)
Date: Mon, 26 Oct 2009

I have been exploring the fascinating world of SMTP and different email
types

Using indy 10.2.3 and indy 10.5.7
with delphi 2007

It appears to me that, while the multipart/alternate allows an html and
a plain text message part to be delivered, some email clients don't
implement this feature preferring to just strip out the HTML

I've only tested it on outlook 2003 and thunderbird 2.0.0.19

any thoughts on this are appreciated

code used to create the message

//-------------------------------------------------------------------------

function TEmailOutgoing.CreateHTMLWithPlainAlternate : TIdMessage;
var IdHTML : TIdText;
    IdText : TIdText;
begin

  // Creation of Parts
  Result := TIdMessage.Create(nil);
  IdHTML := TIdText.Create(Result.MessageParts, nil);
  IdText := TIdText.Create(Result.MessageParts, nil);

  // HEADERS
  Result.Subject := 'Testing HTML V3.1c Email (Plain Text Alternate)';
  {'text/plain', 'text/html', 'multipart/mixed'}
  { 'multipart/related', 'multipart/alternate' }
  Result.ContentType := 'multipart/alternate';

  // Set up HTML Message Part
  IdHTML.ContentType := 'text/html';
  IdHTML.CharSet := 'windows-1250'; // Default = ? 'UTF-8' windows-1250'
  IdHTML.ContentTransfer := 'base64';  // Default = quoted-printable
  //  IdHTML.ParentPart := 0;          // Default = -1
  IdHTML.Body.Add('<html>');
  IdHTML.Body.Add('<head>');
  IdHTML.Body.Add('<title>Title Goes here</title>');
  IdHTML.Body.Add('</head>');
  IdHTML.Body.Add('<body bgcolor="#FFE4B5">');
  IdHTML.Body.Add('<Center><H3>From:' + FServer + '</H3></Center>');
  IdHTML.Body.Add('</br>');
  IdHTML.Body.Add('This is the HTML Email Message Part');
  IdHTML.Body.Add('</br>');
  IdHTML.Body.Add('</body>');
  IdHTML.Body.Add('</html>');

  // Set up Plain Text Messsage part
  IdText.ContentType := 'text/plain';
  IdText.CharSet := 'windows-1250';
  IdText.ContentTransfer := 'base64';
  // IdText.ParentPart := 0;
  IdText.Body.Add('From: ' + FServer);
  IdText.Body.Add('');
  IdText.Body.Add('This is the Plain Text Message Part');
  IdText.Body.Add('');
  IdText.Body.Add('Sent at ' + DateTimetostr(now));

end; { CreateHTMLWithPlainAlternate }

// --------------------------------------------------------------------

in both outlook 2003 and thunderbird what is displayed is the

This is the HTML Email Message Part

when both are set for displaying emails as HTML or as Plain Text

Replies