AttachmentCollectionAdd Method (Attachment) |
Adds the specified
Attachment object to the collection.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public void Add(
Attachment attach
)
Public Sub Add (
attach As Attachment
)
Parameters
- attach
- Type: MailBee.MimeAttachment
The Attachment object which should be added.
Exceptions Examples This sample loads two messages from .EML files, adds all attachments of the second message
to the first message, and saves the first message (which now includes all the original plus added attachments) to disk.
using MailBee;
using MailBee.Mime;
MailMessage msg1 = new MailMessage();
msg1.LoadMessage(@"C:\Docs\TestMail1.eml");
MailMessage msg2 = new MailMessage();
msg2.LoadMessage(@"C:\Docs\TestMail2.eml");
for (int i = 0; i < msg2.Attachments.Count; i++)
{
msg1.Attachments.Add(msg2.Attachments[i]);
}
msg1.SaveMessage(@"C:\Temp\TestMail1.eml");
Imports MailBee
Imports MailBee.Mime
Dim msg1 As New MailMessage
msg1.LoadMessage("C:\Docs\TestMail1.eml")
Dim msg2 As New MailMessage
msg2.LoadMessage("C:\Docs\TestMail2.eml")
Dim i As Integer
For i = 0 To msg2.Attachments.Count - 1
msg1.Attachments.Add(msg2.Attachments(i))
Next
msg1.SaveMessage("C:\Temp\TestMail1.eml")
See Also