IT界の小丑的专栏

单纯的喜欢

asp.net 2.0 如何发送邮件

asp.net2.0发送邮件

public static string SendMail(string smtp, string userName, string password, string title, string content, string send, string accept)
        {
            string result = string.Empty;
            SmtpClient client = new SmtpClient(smtp);
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential(userName, password);
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            MailMessage message = new MailMessage();
            message.SubjectEncoding = Encoding.UTF8;
            message.BodyEncoding = Encoding.UTF8;
            message.From = new MailAddress(send, "loveayu", Encoding.UTF8);
            message.To.Add(new MailAddress(accept, "xiaOhui", Encoding.UTF8));
            message.IsBodyHtml = false;
            message.Subject = title;
            message.Body = content;
            try
            {
                client.Send(message);
                result = "操作成功";
            }
            catch (Exception sendE)
            {
                result = sendE.Message;
            }
            return result;
        } 

 

需要引进的命名空间是

using System.Net;
using System.Net.Mail;

阅读更多
文章标签: asp.net string exception
想对作者说点什么? 我来说一句

ASP.net发送邮件的实例.rar

2008年11月30日 5KB 下载

没有更多推荐了,返回首页

不良信息举报

asp.net 2.0 如何发送邮件

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭