0 votes
by (160 points)

I'm starting out with a *.eml file from a 3rd party email software. We need to basically stuff a fwd/reply into the message and create a new eml/msg file.

I've gotten the Rebex Load(), Attachments.Add(), and Save() methods working.

I'm just not sure how to go about adding anything to the email body and creating a new file.

Any suggestions?

Applies to: Rebex Secure Mail

1 Answer

+1 vote
by (3.9k points)

Hello,

The desired effect can be achieved the following way:

// Load recieved message
recievedMessage.Load(@"c:\temp\testfiles\msg-body-text.msg");
// Create a reply message
var replyMessage = recievedMessage.CreateReply("replier@email.com", ReplyBodyTransformation.KeepOriginal);

// Add reply message to the text body
if (replyMessage.HasBodyText)
{
    // Set the message body according to your needs
    replyMessage.BodyText = "Some reply message\n\n" + replyMessage.BodyText;
}

// Add reply message to the HTML body
if (replyMessage.HasBodyHtml)
{
    // Set the message body according to your needs
    replyMessage.BodyHtml = "<p>Some reply message</p>\n\n" + replyMessage.BodyText;
}

// Save reply message
replyMessage.Save(@"C:\temp\email.eml");
...