当前位置:Gxlcms > asp.net > ASP.Net邮箱发邮件实例代码

ASP.Net邮箱发邮件实例代码

时间:2021-07-01 10:21:17 帮助过:12人阅读

代码如下:
 public static void SendEmail()
    {

        System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
        //这里使用QQ的邮箱来发送测试,如果是其它邮箱,请根据其它邮箱POP3/IMAP/SMTP服务来设置

        client.Host = "smtp.qq.com";
        client.UseDefaultCredentials = false;
        client.Credentials = new System.Net.NetworkCredential("6你的邮箱www.gxlcms.com", "***密码***");
        client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("60**你的*www.gxlcms.com"541**收件人的www.gxlcms.com");
        message.Subject = "主题";
        message.Body = "内容";
        message.BodyEncoding = System.Text.Encoding.UTF8;
        message.IsBodyHtml = true;

        try
        {
            client.Send(message);


        }
        catch
        {

        }

    }

人气教程排行