using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Mail;
namespace emailtest
{
class Program
{
static void Main(string[] args)
{
string flag = sendMail();
if (flag == "true")
Console.WriteLine("成功!");
else
Console.WriteLine("失败!");
Console.WriteLine("/!");
Console.WriteLine(flag.ToString());
Console.Read();
}
public static string sendMail()
{
try
{
MailMessage mailMessage = new MailMessage ();
//mailMessage.From = emailTemplate.From;
mailMessage.From = "632947072@qq.com";
//mailMessage.From = "myDaVinci.com <orders@mydavinci.com>";
//mailMessage.To = emailTemplate.To;
mailMessage.To = "loveguangen@163.com";
mailMessage.Subject ="wge test";
mailMessage.Body = "wge test:test for ferer friends service";
// 以密送形式发送
// mailMessage.Bcc = emailTemplate.Cc;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.Priority = MailPriority.High;
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "632947072@qq.com");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "ainien12345");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", true);
// mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html;
string emailServer = "smtp.qq.com";
SmtpMail.SmtpServer = emailServer;
SmtpMail.Send(mailMessage);
return "true";
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}
}
}