欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c#使用netmail方式發(fā)送郵件示例

 更新時間:2014年01月20日 16:15:56   作者:  
這篇文章主要介紹了c#使用netmail方式發(fā)送郵件的示例,大家參考使用吧

復(fù)制代碼 代碼如下:

/// <summary>
    /// NetMail方式測試通過
    /// </summary>
    private void TestSend()
    {
        System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
        //收件人地址
        mm.To.Add(new System.Net.Mail.MailAddress("xxxxxx@163.com", "Name"));
        //發(fā)件人地址
        mm.From = new System.Net.Mail.MailAddress("xxxxx@sina.com");
        //這個可以不指定
        //mm.Sender = new System.Net.Mail.MailAddress("xxx@sina.com", "SenderName");、

        mm.Subject = "This is Test Email";
        mm.Body = "<h3>This is Testing SMTP Mail Send By Me</h3>";
        mm.IsBodyHtml = true;
        mm.Priority = System.Net.Mail.MailPriority.High; // 設(shè)置發(fā)送郵件的優(yōu)先級
        System.Net.Mail.SmtpClient smtCliend = new System.Net.Mail.SmtpClient();
        //指定郵件服務(wù)器
        smtCliend.Host = "smtp.sina.com";
        //smtp郵件服務(wù)器的端口號 
        smtCliend.Port = 25;  
        //設(shè)置發(fā)件人郵箱的用戶名和地址,使用公共郵件服務(wù)器一般需要提供,不然發(fā)送不會成功
        smtCliend.Credentials = new NetworkCredential("xxxxxxx", "xxxxxxx");

        //指定郵件的發(fā)送方式
        smtCliend.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
        try
        {
            smtCliend.Send(mm);
        }
        catch (System.Net.Mail.SmtpException ex)
        {
            Response.Write(ex.Message);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }

相關(guān)文章

最新評論