Re: Using TIdAttachment

Giganews Newsgroups
Subject: Re: Using TIdAttachment
Posted by:  Remy Lebeau \(Indy Team\) (re…
Date: Fri, 18 Jun 2010

"Tom Hahn" <tha…> wrote in message

> My understanding is that to attach a file to a message I would use
> TIdAttachment.Create(Msg.MessageParts, FileName);

That is correct.

> I see no way to "free" this

Typically, you do not need to.  It becomes owned by the TIdMessage, and will
be freed when the TIdMessage is freed or cleared.

If you want to free the attachment manually, then simply call its Free()
method like any other VCL object, ie:

  Attachment: TIdAttachment;

Attachment := TIdAttachment.Create(Msg.MessageParts, FileName);

> it always "remembers" the file name that was included
> the first time it was used.

Yes.  TIdAttachment has a public FileName property if you want to change the
value after creation.

Remy Lebeau (TeamB)


In response to

Using TIdAttachment posted by Tom Hahn on Sat, 19 Jun 2010