We send emails with attachments with the “Send exchange mail Message”. No issue with this.
Nevertheless, when we try to delete the file which has been sent, we get the message that a process is always using this file. After tests, we found that it is the send activity that don’t dispose the attachments.
Do you know this issue ? Do you have a solution ?
You need to use Invoke Method to call the .Dispose method. If you cannot do this on the MailMessage itself (i.e. you need to keep using the MailMessage) then call it on the attachments object. You can google the Dispose method for more information on how to use it.
I’ve also found this solution but with the “Send Exchange Mail Message” how can we get the object “MailMessage” sent or the object “attachments” in order to call the dispose method on them ?
An alternative way of using the Message activities is to use the Invoke Methods to create the mail message in the first place. Therefore rather than just passing To, From, Subject, Attachment Path through to the activity you can pass through a MailMessage object and also an object of type attachments.
If I get a chance I’ll try to create an example for you. This method will then give you something to dispose once you are done using them and as they are separate you could dispose either the mail message, the attachments or both. We had this problem with files before which were being held in memory and could not be opened.
Hi Richard,
Many thanks for helping us.
We will have no other choice than to use this method.
Is-there somebody from UiPath ?
I think it is a real bug of the “send email” activity that should be resolved. Attachments have to be disposed after sending the email.