[100分]C# 实现QQ邮箱发送HTML代码邮件
代码可以发送到我站内短信或者是我的邮箱232040337@qq.com代码简练追加50分本人保证,绝对不关闭答案.你的回复绝对有价值展示一下您的代码吧\nQQ邮箱发送的题...
代码可以发送到我站内短信 或者是我的邮箱 232040337@qq.com
代码简练 追加50分
本人保证,绝对不关闭答案.
你的回复绝对有价值
展示一下您的代码吧
\n
QQ邮箱发送的题目可以是彩色标题,请问在C#中怎么实现,如果有人实现了这个功能,我马上结贴 展开
代码简练 追加50分
本人保证,绝对不关闭答案.
你的回复绝对有价值
展示一下您的代码吧
\n
QQ邮箱发送的题目可以是彩色标题,请问在C#中怎么实现,如果有人实现了这个功能,我马上结贴 展开
1个回答
展开全部
/// <summary>
/// 发送邮件到外网
/// </summary>
/// <param name="sendMan">发送人</param>
/// <param name="pop3Name">服务端发送帐号</param>
/// <param name="pop3pwd">服务端发送密码</param>
/// <param name="reveiceMan">接收人,多人请用分号分隔</param>
/// <param name="subject">主题</param>
/// <param name="body">内容体</param>
/// <param name="smtpServer">Smtp服务器地址</param>
/// <returns>Bool</returns>
public static bool SendEmail(string sendMan, string pop3Name, string pop3pwd, string reveiceMan, string subject, string body, string smtpServer)
{
try
{
MailMessage MyEmailMessage = new MailMessage();
// string attachFile; //用于构造附件的字符串变量
MyEmailMessage.From = sendMan;
MyEmailMessage.To = reveiceMan;
MyEmailMessage.Subject = subject;
MyEmailMessage.Body = body;
MyEmailMessage.BodyFormat = MailFormat.Text;
MyEmailMessage.Priority = MailPriority.High;
MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置验证用户名
MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", pop3Name);
//设置验证密码
MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pop3pwd);
//构造添加附件
//attachFile = @"D:\test\test.txt";
// MailAttachment mailAttach = new MailAttachment(attachFile);
// MyEmailMessage.Attachments.Add(mailAttach);
//发送电子邮件
SmtpMail.SmtpServer = smtpServer;// 指定smtp服务器
SmtpMail.Send(MyEmailMessage);//发送电子邮件
return true;
}
catch
{
return false;
}
}
/// 发送邮件到外网
/// </summary>
/// <param name="sendMan">发送人</param>
/// <param name="pop3Name">服务端发送帐号</param>
/// <param name="pop3pwd">服务端发送密码</param>
/// <param name="reveiceMan">接收人,多人请用分号分隔</param>
/// <param name="subject">主题</param>
/// <param name="body">内容体</param>
/// <param name="smtpServer">Smtp服务器地址</param>
/// <returns>Bool</returns>
public static bool SendEmail(string sendMan, string pop3Name, string pop3pwd, string reveiceMan, string subject, string body, string smtpServer)
{
try
{
MailMessage MyEmailMessage = new MailMessage();
// string attachFile; //用于构造附件的字符串变量
MyEmailMessage.From = sendMan;
MyEmailMessage.To = reveiceMan;
MyEmailMessage.Subject = subject;
MyEmailMessage.Body = body;
MyEmailMessage.BodyFormat = MailFormat.Text;
MyEmailMessage.Priority = MailPriority.High;
MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置验证用户名
MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", pop3Name);
//设置验证密码
MyEmailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pop3pwd);
//构造添加附件
//attachFile = @"D:\test\test.txt";
// MailAttachment mailAttach = new MailAttachment(attachFile);
// MyEmailMessage.Attachments.Add(mailAttach);
//发送电子邮件
SmtpMail.SmtpServer = smtpServer;// 指定smtp服务器
SmtpMail.Send(MyEmailMessage);//发送电子邮件
return true;
}
catch
{
return false;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询