Do you have some sample code that shows how to get the file attachments out of the message? I'd like to save the attachments to disk.

When you assign the MessageSource property, the TclMailMessage component parses it and extracts all message bodies including text, html, embedded images and file attachments. When the TclMailMessage component parses images and attachments, it does not save the image and/or attachment content in to the memory. It uses external stream object provided by the OnSaveAttachment event. There is also another event - OnLoadAttachment. This event is used for obtaining the attachment source when combining new mail message. You can find a sample of using the OnSaveAttachment event in the MailProgress demo program.


Add Feedback
Hi, when receiving an email with an attachement, and I am requesting MessageSource, it raises an error that it could not find the attachement file at my standard users document directory. Why does it try to access a file that has not been created? I dont get the event "OnSaveAttachment" . THanks for helping
Markus Schlittenbauer (September 9, 2018 at 7:30 PM)
When using the TclMailMessage component together with TclPop3 or TclImap4, the message parts are extracted and saved to the TclMailMessage members. If you save the message source with the TclMailMessage.SaveMessage method or access the messages source via the TclMailMessage.MessageSource property, the message is recomposed. Since the attachmets are not stored in memory, the component calls to the OnLoadAttachment event in order to get a message source stream. As a result, you will not get the original message content. Please use the TclPop3.Response (TclImap4.Response) property instead. Otherwise, you will have to implement both the TclMailMessage.OnSaveAttachment and TclMailMessage.OnLoadAttachment event handers. This is necessary for saving emails with attachments. See the examples:

Sergey Shirokov (November 15, 2019 at 11:49 AM)

Add Feedback