• VS2005发送电子邮件(转)


    /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="sendTo"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static bool SendEmail(string sendTo,string subject,string body)
        {
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Host = "smtp.163.com";
            client.UseDefaultCredentials = false;
            //client.Credentials = new System.Net.NetworkCredential("发件人邮箱", "******");
            client.Credentials = new System.Net.NetworkCredential("你的邮箱", "******");
            //星号改成自己邮箱的密码
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("你的邮箱", sendTo);
            message.Subject = subject;
            message.Body = body;
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.IsBodyHtml = false;
            //添加附件
            //Attachment data = new Attachment(@"附件地址如:e:\a.jpg", System.Net.Mime.MediaTypeNames.Application.Octet);
            //message.Attachments.Add(data);

            try
            {
                client.Send(message);
                return true;
                //MessageBox.Show("Email successfully send.");
            }
            catch (Exception ex)
            {
                return false;
                //MessageBox.Show("Send Email Failed." + ex.ToString());
            }

        } 


    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1685190

  • 相关阅读:
    关于阿里云带宽监控指标记录
    mongodb备份还原
    squid3.5缓存代理实践记录
    kafka依赖zookeeper原因解析及应用场景
    Zookeeper+Kafka集群部署(转)
    dubbo框架提供Main方法运行容器的几种方式(转)
    html标签简介(常用)
    数据库中和表并列的其他对象
    外键约束
    数据库中的约束
  • 原文地址:https://www.cnblogs.com/xugang/p/814099.html
Copyright © 2020-2023  润新知