5
votes

How can I send whole StringList via attachment through Email without saving to the harddrive? I am aware of attachment limits..

3
Did you tried secondary TIdText ? You'd probably need setting CharSet to something like UTF-16 or UCS-2 and maybe it would wrap the lines around 80th character... But maybe it would "just work". TIdText is set to be made to send TStrings - so just try to use it. - Arioch 'The

3 Answers

5
votes

You can use TIdAttachmentMemory instead of TIdAttachmentFile :

StringList := TStringList.Create;
StringList.Append('foo');
StringList.Append('bar');

MemoryStream := TMemoryStream.Create;
StringList.SaveToStream(MemoryStream);
MemoryStream.Position := 0;

IdMessage := TIdMessage.Create(nil);
IdAttachmentMemory := TIdAttachmentMemory.Create(IdMessage.MessageParts,MemoryStream);
2
votes

You could use the StringList.Text porperty. This property can be used to read and write and thus pass the content of a stringlist as a string paramater (instead of trying to pass an object).

0
votes

Why not save it to file and send the file as an attachment?