发邮件
来源:互联网 发布:js两个感叹号使用例子 编辑:程序博客网 时间:2024/04/28 09:20
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();
}
}
}
}
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- 发邮件
- ADO 连接EXCEL显示在DBGRID中找不到可安装的ISAM
- 深入讲解SSH协议的转发概念 转http://network.51cto.com/art/201007/209108.htm
- PHP的四书五经(1)
- 深入讲解SSH协议的转发概念 转http://network.51cto.com/art/201007/209108.htm
- 损失函数(Loss Function)
- 发邮件
- 程序参数处理-getopt
- 多步 ole操作产生错误 这算怎么回事
- watchdog 的使用
- 解决EJB3.0发布时出现javax.naming.nameNotFound的问题
- asp.net 动态生成带有checkbox 的 table ,checkbox 选中和取消 行变色
- [转]Awk基础入门:Awk实例编程之一
- 也记一次域名从新网转出的历程
- 一个股票分析小程序及源代码