如何在asp.net中从我的网站域发送电子邮件 [英] How to send emails from my website domain in asp.net
本文介绍了如何在asp.net中从我的网站域发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我想从我的网站域名发送邮件(www.sample.com)
我写的代码如下。它没有返回任何错误。但是,一旦我在服务器中上传页面,它就不会发送邮件。一旦点击电子邮件发送,它没有收到任何错误,但没有收到邮件。
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient( mail.sample.co.uk, 25 );
smtpClient.Credentials = new System.Net.NetworkCredential( smtpuser@sample.co.uk, pass @ 123 跨度>);
smtpClient.UseDefaultCredentials = true ;
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = false ;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
// 设置From,To和CC
邮件。 From = new System.Net.Mail.MailAddress( smtpuser@sample.co.uk, MyWeb网站);
mail.To.Add( new System.Net.Mail.MailAddress( myemail@gmail.com跨度>));
mail.CC.Add( new System.Net.Mail.MailAddress( myemail1@gmail.com跨度>));
smtpClient.Send(mail);
Response.Write( mail send !!!!!!!);
一旦调用发送方法,我在页面中收到mailsend响应文本。
请帮助
Anjana
解决方案
试试这个:在带有或不带附件的C#中发送电子邮件:通用例程。 [ ^ ] - 我知道它有效!
因此,如果它不适合你,那么你需要查看你的用户名/密码组合作为初学者。
请检查你的垃圾文件夹。有时电子邮件位于Junk / Spam文件夹中。检查以下链接
Smtp邮件引发错误 [ ^ ]
Hello,
I want to send mail from my website domain(www.sample.com)
I have written below code. It is not returning any error. But it is not sending mail once I uploaded the pages in the server. Once click on email send, it is not getting any error, but not receiving the mail.
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("mail.sample.co.uk", 25);
smtpClient.Credentials = new System.Net.NetworkCredential("smtpuser@sample.co.uk", "pass@123");
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = false;
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
//Setting From , To and CC
mail.From = new System.Net.Mail.MailAddress("smtpuser@sample.co.uk", "MyWeb Site");
mail.To.Add(new System.Net.Mail.MailAddress("myemail@gmail.com"));
mail.CC.Add(new System.Net.Mail.MailAddress("myemail1@gmail.com"));
smtpClient.Send(mail);
Response.Write("mail send!!!!!!!");
I am getting the "mailsend" response text in the page once calling the sending method.
Please help
Anjana
解决方案
Try this: Sending an Email in C# with or without attachments: generic routine.[^] - I know it works!
So if it doesn't for you, then you need to look at your username / password combination for starters.
Please check your junk folder. Sometimes email sits in Junk/Spam folder. Check below link
Smtp mail throuws an error[^]
这篇关于如何在asp.net中从我的网站域发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文