Last post Aug 16, 2019 09:11 AM by AddWeb Solution
Aug 16, 2019 07:52 AM|slkim|LINK
I want to send mail using outlook smtp.
I want the email address entered by the user to be the sender and my email address to be the recipient.
Can I change the sender's email address?
string _sender = "email";
string _password = "password";
string toMail = "recipient email";
SmtpClient client = new SmtpClient("smtp-mail.outlook.com");
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(_sender, _password);
client.EnableSsl = true;
client.Credentials = credentials;
var mail = new MailMessage(_sender.Trim(), toMail.Trim());
mail.Subject = Title;
mail.Body = Contents;
catch (Exception ex)
Aug 16, 2019 09:01 AM|PatriceSc|LINK
It is overriden by the actual Outlook account owner? I saw once someone with the same issue in gmail. IMO this is on purpose and most server are configured this way to prevent mail forgery.
My first try would be to use
https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage.replyto?view=netframework-4.8 which should allow to send a possible reply there. If you want to see the original mail right away, you likely have no other option than including this
in the message...
Aug 16, 2019 09:11 AM|AddWeb Solution|LINK
if you want to change sender's email please refer below artical hope you will get your answer as per your requirement.