I have asked this question before for an older version of Rebex.Mail. Back then the provided answer worked, but as of a while ago (unfortunately I don't know since when) it does not seem to work anymore. The previous question can be found here: http://forum.rebex.net/3587/rebex-mail-mailmessage-outlook-message-sent-address-issue
What I want to accomplish is: I want to create and open an Outlook message that can be sent as a different user through Exchange. In the Outlook interface, I want a different address specified in the From field and I want to be able to send the email through Exchange. I am using Outlook 2013 and Exchange 2013.
I have created a simple test project that I have used to try and figure out how I can set the From address in such a way that the message can be sent. Beheer is the display name, TKBUSR990 is the user name and beheer@tkb.nl is the email address. I have tried all versions below and all give me the same error: "You do not have the permission to send the message on behalf of the specified user."
Can you please help?
namespace ConsoleApp4 {
class Program {
static void Main(string[] args) {
var message = new Rebex.Mail.MailMessage();
//message.From = "beheer@tkb.nl";
//message.From = "Beheer";
//message.From = "TKBUSR990";
//message.From = "Beheer <beheer@tkb.nl>";
//message.From = "TKBUSR990 <beheer@tkb.nl>";
//message.From = "Beheer, beheer@tkb.nl";
message.From = "TKBUSR990, beheer@tkb.nl";
message.To = "tkb_test@tkb.nl";
message.Subject = "Test";
message.BodyHtml = "<p>This is a test.</p>";
message.Headers.Add("X-Unsent", "1");
message.Save("C:\\Temp\\Test.msg", Rebex.Mail.MailFormat.OutlookMsg);
System.Diagnostics.Process.Start("C:\\Temp\\Test.msg");
}
}
}