🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1882

TIdMessage text+(html+graphic)

#1882
From: Hans Galema
Date: Sat, 23 Sep 2006 09:25
111 lines
3959 bytes
Turbo C++ Indy9
Trying to use TIdmessage and TIdSMTP to compose and send mails.

For mails who consist of
-text only
-html only
-text+html
-text+attachment
-text+html+attachment

all works like expected. I mean the Content-Type's
and boundaries are the same as when composed and sent
with thunderbird.

-text+(html+graphic) I cannot handle this like it should.

First: the Content-Type's are reversed. Thunderbird does it like
/*
Subject: thunderbird text+(html+graphic)
Content-Type: multipart/alternative;
  boundary="------------080600050801000102040000"

This is a multi-part message in MIME format.
--------------080600050801000102040000
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello you. Here a picture:

--------------080600050801000102040000
Content-Type: multipart/related;
  boundary="------------050907000600090804020203"
  */

But here I get the multipart/related first. Does not matter
what I do with Content-Type

As there are two Content-Type's I wonder how I should tell that
to TIdMessage.

The mailreaders Thunderbird and OE (if the message is receied)
do not care about the reversing.

Second: If I send it to mij gmail.com account the message
is received. If I send it to the account at my provider the
message is not received. No exceptions thrown and the .eml
produced.

Here the code I tried:

  AnsiString GraphicFileName = "pluis.gif";

  AnsiString Text =
	"How are you?\r\n"
	"I'm doing well.\r\n"
	"Please have a ..."
	;


   AnsiString HtmlTextWithGraphic =
	"<html><body>\r\n<font color=\"blue\" size=\"+2\">"
	"How are you?<br>\r\n"
	"<img src=\"cid:" + GraphicFileName + "\" /> "
	"I'm doing well.<br>\r\n"
	"Please have a ..."
	"</font></body></html>\r\n"
	;

void __fastcall TForm2::Button6Click(TObject *Sender)
{
   // Text+(Html+Graphic)

   TIdMessage *IdMessage = new TIdMessage ( this );

   TIdText *text1 = new TIdText(IdMessage->MessageParts, NULL);
   text1->Body->Text = Text;
   text1->ContentType = "text/plain";

   TIdText *text2 = new TIdText(IdMessage->MessageParts, NULL);
   text2->Body->Text = HtmlTextWithGraphic;
   text2->ContentType = "text/html";

   AnsiString FilePath = ExtractFilePath(ParamStr(0)) + GraphicFileName;

   TIdAttachment *IdAttachment = new TIdAttachment(
		IdMessage->MessageParts, FilePath );
   IdAttachment->ContentType = GetMIMETypeFromFile(FilePath);
   IdAttachment->FileName    = GraphicFileName;
   IdAttachment->ContentID   = GraphicFileName;

   IdMessage->Subject = Subject + " Text+(Html+Graphic)";
   IdMessage->From->Address = FromAddress;
   IdMessage->From->Name = FromName;
   IdMessage->Recipients->EMailAddresses = EMailAddresses;

   IdMessage->ContentType = "multipart/related; type=\"multipart/alternative\"";

   IdMessage->SaveToFile("IdMessage.6.eml", false);

   IdSMTP->Host = Host;
   IdSMTP->Port = Port;
   IdSMTP->Connect(1000);
   IdSMTP->Send(IdMessage);
   IdSMTP->Disconnect();

    delete IdMessage;
}

So if someone could give me a hand?

Hans.
Technical Details
Message-ID: <4514ff01@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b4f28d34b773949b,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sat, 23 Sep 2006 11:25:10 +0200
From: Hans Galema <notused@notused.nl>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: TIdMessage text+(html+graphic)
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 145.98.201.248
Message-ID: <4514ff01@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1159003905 145.98.201.248 (23 Sep 2006 02:31:45 -0700)
Lines: 111
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail