System. net. Mail. smtpclient Client = New System. net. Mail. smtpclient ();
Client. Host = " Smtp.163.com " ;
Client. usedefacrecredentials = False ;
Client. Credentials = New System. net. networkcredential ( " Your 163 email address " , " Password " );
Client. deliverymethod = System. net. Mail. smtpdeliverymethod. Network;
System. net. Mail. mailmessage message = New System. net. Mail. mailmessage ( " Your 163 email address " , " Recipient address " );
Message. Subject = " Topic Test " ;
Message. Body = " Asp.net send email " ;
Message. bodyencoding = System. Text. encoding. utf8;
Message. isbodyhtml = True ;
// To add an attachment, upload the attachment to the server first)
System. net. Mail. Attachment data = New System. net. Mail. Attachment ( @" Upfile \ fj.rar " ,
System. net. Mime. mediatypenames. application. octet );
Message. attachments. Add (data );
Try
{
Client. Send (Message );
Response. Write ( " Email successfully send. " );
}
Catch (Exception ex)
{
Response. Write ( " Send email failed. " + Ex. tostring ());
}