I have a ASP.NET Application that add data to a DataBase and get data from this database. This Application is for creating a guestconnection to our network. If a User is add to the database and the Radius Server give the ok the User get e email with his login data. username and password. I want to make a html mail. But I don't know how I can do this in ASP.NET and so I read a few tutorials about that and I found this Code:
我有一个ASP.NET应用程序,它将数据添加到DataBase并从此数据库中获取数据。此应用程序用于创建到我们的网络的访客连接。如果用户被添加到数据库并且Radius服务器给出了ok,那么用户将获得带有他的登录数据的电子邮件。用户名和密码。我想制作一个HTML邮件。但我不知道如何在ASP.NET中执行此操作,因此我阅读了一些有关该内容的教程,并且我找到了此代码:
http://www.codeproject.com/Articles/12182/ASP-NET-Sending-mail-using-SMTP-in-HTML-format-us
http://www.codeproject.com/Articles/12182/ASP-NET-Sending-mail-using-SMTP-in-HTML-format-us
this is my code:
这是我的代码:
MailMessage mail = new MailMessage();
mail.To = "<here is my company email>";
mail.From = "test@domain.de";
mail.BodyFormat = MailFormat.Html;
mail.Subject = "testheader";
mail.Body =
"<html><body><Table><tr><td>Hi,</td></tr><tr><td>Details of the Statistics :</td></tr></Table></body></html><html><body>" +
"sometext" +
"</body></html><html><body><Table><tr><td> </td></tr><tr><td>NOTE: This is an automated mail. Please, do not reply.</td></tr>" +
"<tr><td>*Green coloured rows indicates temporary demos</td></tr>" +
"<tr><td>**All statistics are based on the page naming conventions Eg., 22_10_2005_</td></tr>" +
"<tr><td> </td></tr><tr><td>Regards,</td></tr><tr><td>some text,</td></tr><tr><td>some text,</td></tr>" +
"<tr><td> Some text </td></tr></table></body></html>";
SmtpMail.SmtpServer = "<smtp ip>";
SmtpMail.Send(mail);
I try this and get the error that:
我试试这个并得到错误:
The server rejected the sender address. The server response was: 530 5.7.1 Client not authenticated
The Ip is right but what I must do for the authenticated..how i can do this?
Ip是正确的,但我必须为经过验证的事情做些什么。我能做到这一点吗?
1 个解决方案
#1
2
You have to configure the SMTP server mailSettings in your Web.config
file:
您必须在Web.config文件中配置SMTP服务器mailSettings:
<system.net >
<mailSettings>
<smtp deliveryMethod="Network" from="someaddress@classifiedspak.com">
<network
host="mail.classifiedspak.com"
userName="someaddress@classifiedspak.com "
password="*************"
port="25" />
</smtp>
</mailSettings>
</system.net>
#1
2
You have to configure the SMTP server mailSettings in your Web.config
file:
您必须在Web.config文件中配置SMTP服务器mailSettings:
<system.net >
<mailSettings>
<smtp deliveryMethod="Network" from="someaddress@classifiedspak.com">
<network
host="mail.classifiedspak.com"
userName="someaddress@classifiedspak.com "
password="*************"
port="25" />
</smtp>
</mailSettings>
</system.net>