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);