如何解决asp.net电子邮件SmtpMail.SmtpServer.Insert0,“”;
| 我有一个asp.net页面,向我发送电子邮件。SmtpMail.SmtpServer.Insert(0,\"\");
工作正常。
这是什么意思 ?当我将其更改为“ 1”时,它将失败。
When I say SmtpMail.SmtpServer.Insert(0,\"\")
,我要完全设置为SMTP服务器吗?
解决方法
其实
SmtpMail.SmtpServer.Insert(0,\"\");
什么也没做。
SmtpServer
属性的类型为String,因此您基本上是在调用string.Insert(int,string),这不会影响您要在其上插入insert的字符串,但是会返回一个新的string实例,其中包含您要插入的内容。
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);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。