邮件发送

**//// <summary>
/// 发送邮件
/// </summary>

public static bool SendEmailForGetpass(string name, string email, string random)
{
    
try
    
{
        MailAddress from 
= new MailAddress("xxx@163.com""ShundeBK.cn");
        MailAddress to 
= new MailAddress(email, name);
        MailMessage message 
= new MailMessage(from, to);
        message.Subject 
= "顺德百科 ShundeBK.cn 取回密码";

        message.Body 
= @"<a href='http://shundebk.cn/passport/Setpass.aspx?code=" + random + "' target='_blank'>取回密码</a>;
        message.Priority = MailPriority.High;
        message.IsBodyHtml 
= true;

        SmtpClient client 
= new SmtpClient("smtp.163.com");
        client.Credentials 
= new System.Net.NetworkCredential("xxx""xxx");
        client.Send(message);

        
return true;
    }

    
catch (Exception e)
    
{
        
throw e;
        
return false;
    }

}

原文地址:https://www.cnblogs.com/yibinboy/p/1304142.html