These are chat archives for IndySockets/Indy

17th
Apr 2018
Jacek
@jaclas
Apr 17 2018 12:59
I need to clone a completed TIdMessage object. How to do it correctly? Is SaveToStream / LoadFromStream enough?
Kudzu
@czhower
Apr 17 2018 13:29
that should get most, if not all.
Remy Lebeau
@rlebeau
Apr 17 2018 16:51
@jaclas that depends on how you have populated the TIdMessage, and what the values of the NoEncode and NoDecode properties are set to
Ludwig Behm
@lbehm
Apr 17 2018 18:26
I have a question about TIdMessage, too. I need to insert a TGraphic into a HTML-Mail. I assume I have to use TIdAttachmentMemory and reference the filename in the img-src?
More important: how would you import a TGraphic into a TIdAttachmentMemory?
Remy Lebeau
@rlebeau
Apr 17 2018 18:36
@lbehm See http://www.indyproject.org/Sockets/Blogs/RLebeau/2005_08_17_A.aspx and http://www.indyproject.org/Sockets/Blogs/RLebeau/20080116.aspx for how to produce HTML emails with embedded images. As for using TGraphic, you can save it to a TStream first, such as TMemoryStream, and then construct the TIdAttachmentMemory from that TStream. Or, you can save the TGraphic to a temp file and use TIdAttachmentFile with its FileIsTempFile property set to True so the file will be deleted when the attachment is freed. Or, you could write your own TIdAttachment class that overrides OpenLoadStream() and CloseLoadStream() to return/free a temp TStream that the TGraphic has been saved to and which Indy will read from to get the data to send.
Ludwig Behm
@lbehm
Apr 17 2018 18:38
Awesome, thank you!