0 votes
by (160 points)

Hi, We are trying to create and save a OutlookMsg as below.

Approach 1:

MailMessage message = new MailMessage();
message.MessageId = new Rebex.Mime.Headers.MessageId(Guid.NewGuid().ToString());
message.Subject = "Subject";
message.BodyHtml = "Hello RebEx";

MemoryStream mailStream = new MemoryStream();
message.Save(mailStream, MailFormat.OutlookMsg);

Approach 2 :

Create email as above and then create reply

MailMessage newMessage = message.CreateReply(new Rebex.Mime.Headers.MailAddress("static@test.com"), ReplyBodyTransformation.None, true);

MemoryStream mailStream = new MemoryStream();
newMessage.Save(mailStream, MailFormat.OutlookMsg);

I have tried 2 ways to create and saved message.

But when I open that saved message, I do not get Send button, it shows Reply.. buttons.

My requirement is to create email using code with some existing template and then allow user to edit and send using Outlook.

1 Answer

+1 vote
by (69.8k points)
Best answer

To achieve your requirement please add the "X-Unsent: 1" header to the mail. It can be done like this:

// create message ...

// add "X-Unsent: 1" header 
message.Headers.Add("X-Unsent", "1");

// save message ...
by (160 points)

Thanks it worked.