Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

November 11, 2005

Copying Attachments from one Email Object to Another

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.


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.