Re: Email Message Composition Dialog Object

Giganews Newsgroups
Subject: Re: Email Message Composition Dialog Object
Posted by:  Remy Lebeau (re…
Date: Tue, 19 Feb 2013

Adam wrote:

> The idea is to have a unit that could be called to populate everything
> required for sending a message.

Indy 10 already has a helper class for a similar purpose.  Look at various
classes in the IdMessageBuilder.pas unit, such as TIdMessageBuilderPlain
and TIdMessageBuilderHtml.  You would still have to fill in the Sender, Recipients,
and Subject yourself, but the Body and Attachments are handled for you.
I wrote an article about its basic usage (some of the details have changed
slightly over the years, though):

New HTML Message Builder class

> I think the basics (such as the receipient, message body, etc) would
> be pretty straight forward

Recipients, yes.  Body, no.  Have a look at the following article for an
example of why the Body is actually not straight-forward:

HTML Messages.

> but I'm not as sure about passing through attachments.

Attachments are slightly more straight forward than the Body, but only slightly.
You do have to take the TIdMessagePart.ParentPart property into account,
as attachments at different levels of nesting mean different things.  The
kind of "attachments" you are thinking of would be attachments that have
a ParentPart value of -1, but attachment objects can appear at other levels
as well (embedded resources linked by HTML, for instance).

Remy Lebeau (Indy Team)


In response to

Email Message Composition Dialog Object posted by Adam H on Mon, 18 Feb 2013