Re: Using TIdAttachment

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

"Tom Hahn" <tha…@hahntech.com> wrote in message
news:556653957298592826.743106thahn-hahntech.c…@news.atozed.com...

> 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:

{code:delphi}
var
  Attachment: TIdAttachment;

Attachment := TIdAttachment.Create(Msg.MessageParts, FileName);
....
Attachment.Free;
{code}

> 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)

Replies

In response to

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