通过SMTP发送电子邮件 [英] Sending Email through SMTP

查看:796
本文介绍了通过SMTP发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过SMTP发送邮件。我的要求是我需要从两个邮件Id'发送邮件。从一些代码我需要从abc@mydomain.com发送邮件,并从我需要从xyz@mydomail.com发送邮件的一些代码。这可以通过SMTP吗?



我可以通过一个电子邮件ID发送电子邮件,但无法通过其他邮件ID发送邮件。



以下是我的代码。



SmtpClient objSmtp =新的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);

消息。 To.Add(abc@gmail.com);

message.Subject =嗨;

message.Body =嗨;

message.IsBodyHtml = true;

ServicePointManager.ServerCertificateValidationCallback = delegate(object s,X509Certificate certificate,X509Chain chain,SslPolicyErrors sslPolicyErrors){return true; };

objSmtp.Send(消息);



此代码适用于一个邮件ID。



但是当我使用第二个邮件ID时,邮件将转到BadMail direcory。 BDR文件中的错误消息是

无法传递此消息,因为遇到了以下错误:此消息是无法传递的传递状态通知。。

具体错误代码为0xC00402C7。


邮件发件人< >







请帮我解决此问题。



先谢谢。

解决方案

参见 https://www.google.co.uk/search?q = 0xC00402C7& aq = f& oq = 0xC00402C7& aqs = chrome.0.57& sourceid = chrome& ie = UTF-8 [ ^ ]。< /集团kquote>

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.

解决方案

See https://www.google.co.uk/search?q=0xC00402C7&aq=f&oq=0xC00402C7&aqs=chrome.0.57&sourceid=chrome&ie=UTF-8[^].


这篇关于通过SMTP发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆