如何从我自己的网站发送邮件 [英] how to send mail from my own website
本文介绍了如何从我自己的网站发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下编码从我自己的网站发送邮件但无法发送
i used below coding to send mail from my own website but unable to send
try
{
var fromAddress = "contactus@investemu.com";
var toAddress = txtfrmmailid.Text.ToString();
string fromPassword ="mypassword";
string subject = txtsubject.Text.ToString();
string body = "From: Carshop\n";
body += "Email: contactus@investemu.com\n";
body += "Subject: " + txtsubject.Text + "\n";
body += "Message: \n" + txtcomments.Text + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.investemu.com";
smtp.Port = 25;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}
catch (Exception err)
{
errormessage(err.Message);
}
private void errormessage(string msg)
{
Response.Write("<script type=Text/Javascript> alert('" + msg + "'); </script>");
}
推荐答案
我使用的代码(对我有用)在这里:使用或不使用附件在C#中发送电子邮件:通用例程。 [ ^ ] - 它与你的没有什么不同,但是你可能会发现从已知的工作代码开始更容易!
The code I use (which works for me) is here: Sending an Email in C# with or without attachments: generic routine.[^] - it''s not that different from yours, but you might find it easier to start with known working code!
如果从任何门户网站获得上面的代码那么应该有您的防病毒设置问题
某些防病毒软件会阻止此类邮件发送。因为我之前面对它可能是问题所在。
看看并告诉我:))
if you got above code form any portal then there should be issue with your antivirus settings
some of antivirus are blocking this kind to sending email. as I face it before so it may be the issue.
have a look and let me know :)
这篇关于如何从我自己的网站发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文