asp.net电子邮件SmtpMail.SmtpServer.Insert(0,“”);
本文关键字:电子邮件 net SmtpMail SmtpServer Insert asp | 更新日期: 2023-09-27 17:57:45
我有一个asp.net页面,可以向我发送电子邮件。
SmtpMail.SmtpServer.Insert(0, "");
工作良好。
这是什么意思?当我将其更改为SmtpMail.SmtpServer = "127.0.0.1";
时,它将失败。
When I say SmtpMail.SmtpServer.Insert(0, "")
,我将什么设置为SMTP服务器?
实际
SmtpMail.SmtpServer.Insert(0, "");
什么也不做。
SmtpServer
属性的类型是String,所以您基本上是在调用String。Insert(int,string),它不会影响您调用Insert的字符串,但会返回一个新的字符串实例,其中包含您试图插入的内容。
SmtpMail.SmtpServer = "google.com";
SmtpMail.SmtpServer = SmtpMail.SmtpServer.Insert(0, "mail.");
// now SmtpMail.SmtpServer will be "mail.google.com"
正如您所知,SmtpServer已经过时了。您应该使用SmtpClient
:http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx
SmtpClient client = new SmtpClient();
//...
MailMessage message = new MailMessage(from, to);
// setup mail properties...
client.Send(message);