Discuss this help topic in SecureBlackbox Forum
MIME: Create message with attachment from memory
To add the attachment from memory use TElMessage.AttachData() method. It creates a message with the following structure:
The following code snippet creates a plain text message with an attached data. 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.AttachData("", "my data", data, 0, data.Length);
// step 5
using (FileStream f = new FileStream(@"D:\test.eml", FileMode.Create, FileAccess.Write))
{
message.AssembleMessage(f);
f.Close();
}