Console.Write("Begin");
MailMessage mail = new MailMessage(sender, Receiver);
SmtpClient smtp = new SmtpClient(server);
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(sender, sender_pass);
mail.Subject = subject;
if (Html == false)
{
mail.Body=ParseTags(contentText);
}
mail.IsBodyHtml = Html;
//设置正文的编码形式.这里的设置为取系统默认编码
mail.BodyEncoding = System.Text.Encoding.Default;
///这里为添加附件的代码,主要用的是FileUpload控件,fileUpload是FileUpload控件的ID
if (fileUpload.PostedFile.ContentLength != 0)
{
string fileName = fileUpload.PostedFile.FileName;
// 该类的构造函数有6个重载,下面演示创建一个Attachment类的实例的两种常用方式。
Attachment Item = new Attachment(fileName, MediaTypeNames.Text.Plain);
mail.Attachments.Add(Item);
}
mail.sent();
Console.Write("Begin");!!
大哥,这是控制台程序里面的输出代码。汗·····