SOLVED

Sending SMTP Message with a different sender then the logged in account.

New Contributor
I have written a C# application to send an email message using my Office 365 Exchange server.
I can send the message perfectly if I specify the “From” as the Mailbox I log in as (both highlighted below).
But I can’t do it if I log in as Mailbox, and send as “Shared Mailbox” address.
Here is my code, can this be done?
 
  MailMessage mail = new MailMessage();               
                mail.From = new MailAddress("SHAREDMAILBOX.AT.SOMEWHERE.com");
                mail.To.Add("MYACCOUNT.AT.SOMEWHERE.com");
                mail.Subject = "Test Mail";
                String mess = "Hello World";
                mail.Body = myString;
               
                SmtpClient SmtpServer = new SmtpClient("smtp.office365.com");
                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("MAILBOX.AT.SOMEWHERE.com", "MYPASSWORD");
                SmtpServer.EnableSsl = true;
                SmtpServer.Send(mail);
2 Replies
best response confirmed by Michael530 (New Contributor)
Solution
Hi @Michael530

I am pretty sure, from my time doing exchange migrations that this can be resolved by giving the mailbox which you are authenticating with send as permissions over the other mailbox (es) in the exchange admin centre. If I also remember there is some propagation time so apply send as permissions, wait an hour then try sending.

Let me know how it goes!

Best, Chris