UsingSystem. Collections. Generic;
UsingSystem. text;
UsingSystem. net;
UsingSystem. net. mail;Try
{
// The code must be gb2312.
Encoding encoding = encoding. getencoding (936 );
Mailmessage message =NewMailmessage (
New mailaddress (" your mailbox ", " 5 ", encoding), // The first is the sender's address, the second parameter is the sender
NewMailaddress (textbox1.text ));// Recipient's email
Message. subjectencoding = encoding;
Message. Subject = textbox2.text;// Title
Message. bodyencoding = encoding;
message. body = textbox3.text; // subject
smtpclient = New smtpclient (" smtp.163.com "); // mailbox server
smtpclient. credentials = New networkcredential (" your mailbox username ", " your mailbox password " ); // user name and password of the mailbox
Smtpclient. Timeout = 999999;
Smtpclient. Send (Message );
}
Catch(Exception ex)
{
Throw NewException (ex. Message );
}