Article View: borland.public.cppbuilder.internet.socket
Article #1974Wrapper for TIdMessage used by TIdSMTP
From: Hans Galema
Date: Fri, 22 Sep 2006 17:22
Date: Fri, 22 Sep 2006 17:22
47 lines
2566 bytes
2566 bytes
Remembering this thread about a handy interface for sending mail: http://tinyurl.com/qvd89 and having installed Turbo C++ Explorer I migrated a bcb5 project. I'm forced now to take another component for TNMSMTP so decided for Indy9 TIdSMTP. I soon found out that one has to take TIdMessage also which is a nice design to compose and see the mail before it is handed over to the sender. Oh.. and one needs TIdText and TIdAttachment too. So I made a wrapperclass (TMyIdMessage) for TIdMessage with only four methods to be used by the programmer. The wrapper cares for TIdText and TIdAttachment. The four methods are: SetText( AnsiString Text ); SetHtmlText( AnsiString Text ); AddHtmlGraphic( AnsiString FileName ); AddAttachment( AnsiString FileName ); The programmer only uses TIdSMTP and TMyIdMessage. This is sufficient for mails which are composed as: -text only -html only -text+html -text+attachments -text+html+attachments -text+(html+graphic) -text+(html+graphic)+attachments Is it ready now? Well not completely. As mentioned in another post the resulting boundarys and ContentType's are different from what they have to be. (The wrapper does not set values for encoding or contenttype, except for IdText::ContentType). The nice thing is that thunderbird and OE don't seem to care as they display as intended. I will test further this weekend. For text+(html+graphic)+attachments I will put all code (without using the wrapper) in a TButton eventhandler, try it and then post it here and hopefully get help to get it right. Then I will adapt the wrapper and publish it here. Hans.
Technical Details
Message-ID:
<45141d73@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,182eed52ef20b4b5,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 22 Sep 2006 19:22:51 +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: Wrapper for TIdMessage used by TIdSMTP Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 145.98.201.248 Message-ID: <45141d73@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1158946163 145.98.201.248 (22 Sep 2006 10:29:23 -0700) Lines: 54 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail