Is it possible to create a file into an Stream and then try to send it as an
attachment with Indy TIdAttachment??
Thanks
Carlos
> Is it possible to create a file into an Stream and then
> try to send it as an attachment with Indy TIdAttachment??
Not in Indy 9, no. It does not support streams as attachments, only files.
Indy 10 supports streams as attachments, as well as custom attachment type
since TIdAttachment is now a base class for other descendant classes.
Gambit
IdMessage:
Type
TAttachmentType = (atFile, atStream); //new
TIdAttachment = class(TIdMessagePart)
protected
...
FAttachmentType:TAttachmentType;//new
FStream:TStream;//new
public
...
property AttachmentType: TAttachmentType read FAttachmentType write
FAttachmentType;//new
property Stream: TStream read FStream write FStream;//new
end;
procedure TIdAttachment.Assign(Source: TPersistent);
...
AttachmentType := mp.AttachmentType;//new
Stream := mp.Stream;//new
end;
end;
procedure TIdAttachment.Encode(ADest: TStream);
begin
with
TIdMessageEncoderInfo(TIdMessageParts(Collection).MessageEncoderInfo).Messag
eEncoderClass
.Create(nil) do try
Filename := Self.Filename;
if AttachmentType = atFile then//new
begin//new
Encode(Self.StoredPathname, ADest); //old
end//new
else//new
begin//new
Encode(Stream, ADest);//new
end;//new
finally Free; end;
end;
To use:
MyAttach := TIdAttachment.Create(MyMsg.MessageParts, cFileName);
MyAttach.AttachmentType := atStream;
MyAttach.Stream := MyStream;
MyAttach.ContentType := 'text/plain';
"Carlos Guerra" <cgu...@aduasys.com> wrote in message
news:4101b547$1...@newsgroups.borland.com...
Regards
"Carlos Guerra" <cgu...@aduasys.com> wrote in message
news:4101b547$1...@newsgroups.borland.com...