Discuss this help topic in SecureBlackbox Forum
MIME: Create message with attachment from file
The simplest way to add attachments is to use TElMessage.AttachFile() method. It creates a message with the following structure:
The following code snippet creates a plain text message with an attached file. To specify another content type for the attached data, pass the desired type as the first parameter.
C#:
// step 1: create objects
TElPlainTextPart textPart = new TElPlainTextPart();
TElMessage message = new TElMessage(textPart, "My Cool E-mail Client");
// step 2: setup message parameters
message.From.AddAddress("Secretary", "sender@company.com");
message.To_.AddAddress("Addressee", "address@domain.com");
message.SetSubject("Test Message");
// step 3: put message text
textPart.SetText(@"Just a test message");
// step 4: attach a file
message.AttachFile("", @"D:\cert.cer");
// step 5
using (FileStream f = new FileStream(@"D:\test.eml", FileMode.Create, FileAccess.Write))
{
message.AssembleMessage(f);
f.Close();
}