Hi,
We use System.Net.Mail.SmtpClient class in C# to send mails using an Exchange 365 mailbox. This is the outline of the code:
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("Valid O365 Exchange User Email address", "Password");
smtpClient.Port = 587;
smtpClient.Host = "smtp.office365.com";
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
.............
MailMessage msg = new MailMessage();
msg.From = new MailAddress("*** Email address is removed for privacy ***"); // non-existent mailbox address
msg.Sender = new MailAddress("*** Email address is removed for privacy ***"); // Valid O365 user used in credentials above
..............
// add subject, body etc. and send
This was working till recently and in the received mail we used to see sender as "*** Email address is removed for privacy *** on behalf of *** Email address is removed for privacy ***".
However, this has stopped working recently and we are getting error. There is no change in code or the exchange configuration. Please let us know if this is due to any recent change and what is the possible fix for this error:
System.Net.Mail.SmtpException: Transaction failed. The server response was: 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message
Thanks
Pavan
https://www.crowcanyon.com/