I am sending mails through SMTP. My requirement is I need to send mails from two mail Id's. From some piece of code i need to send mail from "abc@mydomain.com" and from some piece of code i need to send mail from "xyz@mydomail.com". Is this possible through SMTP??
I am able to send email form one email id, but unable to send mail through another mail id.
Below is my code.
SmtpClient objSmtp = new SmtpClient("pod51021.outlook.com");
System.Net.NetworkCredential("abc@mydomain.com", "abc123");
objSmtp.EnableSsl = false;
objSmtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
objSmtp.UseDefaultCredentials = false;
MailMessage message = new MailMessage();
message.From = new MailAddress("abc@mydomain.com");
message.To.Add("abc@gmail.com");
message.Subject = "Hi";
message.Body = "Hi";
message.IsBodyHtml = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
objSmtp.Send(message);
This code works fine for one mail id.
But when i use second mail id, mail is going to BadMail direcory. The error message in BDR file is "
Unable to deliver this message because the follow error was encountered: "This message is a delivery status notification that cannot be delivered.".
The specific error code was 0xC00402C7.
The message sender was <>.
".
Please help me to resolve this issue.
Thanks in Advance.