Question:
I need a bit of help, I need to add the attachments from one email to a new email.
I have tried…
<font face=courier size=2>
For I = 0 To ProcessedEmail.NumAttachments - 1
email.AddFileAttachment(ProcessedEmail.GetAttachmentFilename(I))
Next
</font>
Where email is the new email and ProcessedEmail is the email I want to get the attachments from and add to email.
Answer:
The AddFileAttachment method is used to add an attachment from a file that exists in the filesystem. Here is code to copy attachments from one email object to another:
<font face=courier size=2>
For I = 0 To e.NumAttachments - 1
email.AddDataAttachment(e.GetAttachmentFilename(I),e.GetAttachmentData(I))
Next
</font>
Warning: In answering this question, I found an issue. The methods and properties should be identical between Chilkat .NET, Chilkat ActiveX, and Chilkat C++. However, in this case I noticed that the method argument order is swapped. For Chilkat .NET, the AddDataAttachment arguments are (filename,data), but for Chilkat ActiveX, the arguments are (data,filename). Unfortunately, it’s not possible to fix without breaking backward compatibility so we’ll have to live with it.