Hi Team,
We have an archival solution that where MS Exchange is source. As part of this, we have an Outlook Add-in for achieving certain use cases like user defined archival. One particular functionality of this Add-in is a send a mail. Please find below pseudo-code for the same. This functionality works fine with Outlook in an Exchange On-Premises environment, and even works well in Exchange Online environment. Now, as we are planning to support Exchange Hybrid, we see that when the mail is sent from an Online Mailbox to an On-premises mailbox, some of the properties namely, the message class and the custom properties required by our application, are not retained. This is only seen when sending from Online to On-Premise, it works fine in case of sending a mail from On-Premise to On-Premise or Ex Online to Ex Online.
using Outlook = Microsoft.Office.Interop.Outlook;
public void sendMail(Outlook.Application a)
{
Outlook.MailItem theMail = null; /
try
{
theMail = (Outlook.MailItem)a.CreateItem(Outlook.OlItemType.olMailItem);
theMail.MessageClass = "CustomMessageClass"; // Changes not retained
theMail.To = recepient;
theMail.Subject = "The Subject";
//Code to set custom MAPI properties - Changes not retained
theMail.DeleteAfterSubmit = true;
((Outlook._MailItem)theMail).Send();
}
catch (Exception ex)
{
// Log Exception
}
finally
{
// Free Resources
}
}