C#.net用QQ服务邮箱发邮件2
C#.net用QQ服务邮箱发邮件2
using System;
using System.Collecti.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Sy
C#.net用QQ服务邮箱发邮件2
using System;using System.Collecti.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Mail;
namespace PowerOff
{
public partial class 邮件发送 : Form
{
public 邮件发送()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string mailServer = smtp.qq; //qq的smtp服务器
string mailSenderAddress = 26927828@qq; //发送服务的qq
string mailSenderPass = 666666; //发送服务的qq密码
string mailtoAssress = 2254952@qq; //发送给的qq
string mailDisaplyame = 邮件显示的主题; //邮件显示的主题
bool ds = SendWebMail(mailSenderAddress, mailtoAssress, 邮件标题, 邮件内容, mailDisaplyame, mailSenderPass, mailServer);
}
public bool SendWebMail(string mailSenderAddress, string mailtoAssress, string title, string body, string mailAccount, string mailPass, string mailServer)
{
try
{
//创建smtpclient对象
Mail.SmtpClient client = new SmtpClient();
client.Host = mailServer;//qq的smtp服务器是 smtp.qq
string from = mailSenderAddress;
string pwd = mailPass;
client.UseDefaultCredentials = false;
client.Credentials = new etworkCredential(from, pwd);
client.DeliveryMethod = ;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
string senderDisplayame = mailAccount;//这个配置的是发件人的要显示在邮件的名称
//string recipientsDisplayame = 都云;//这个配置的是收件人的要显示在邮件的名称
MailAddress mailfrom = new MailAddress(mailSenderAddress, senderDisplayame, encoding);//发件人邮箱地址,名称,编码UTF8
MailAddress mailto = new MailAddress(mailtoAssress);//收件人邮箱地址,名称,编码UTF8
//创建mailMessage对象
Mail.MailMessage message = new MailMessage(mailfrom, mailto);
message.Subject = title;
//正文默认格式为html
message.Body = body;
message.IsBodyHtml = true;
message.BodyEncoding = encoding;
message.SubjectEncoding = encoding;
client.Send(message);
return true;
}
catch { return false; }
}
}
}
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
上传时间: 2024-02-10 11:22:07
推荐阅读
留言与评论(共有 16 条评论) |
本站网友 伊川租房 | 24分钟前 发表 |
string mailServer) { try { //创建smtpclient对象 Mail.SmtpClient client = new SmtpClient(); client.Host = mailServer;//qq的smtp服务器是 smtp.qq string from = mailSenderAddress; string pwd = mailPass; client.UseDefaultCredentials = false; client.Credentials = new etworkCredential(from | |
本站网友 安全评估 | 29分钟前 发表 |
Form { public 邮件发送() { InitializeComponent(); } private void button1_Click(object sender | |
本站网友 脱发偏方 | 13分钟前 发表 |
C#.net用QQ服务邮箱发邮件2 using System; using System.Collecti.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Mail; namespace PowerOff { public partial class 邮件发送 | |
本站网友 牛皮癣治疗偏方 | 25分钟前 发表 |
string title | |
本站网友 万通筋骨片 | 1分钟前 发表 |
mailtoAssress | |
本站网友 食品的分类 | 19分钟前 发表 |
mailto); message.Subject = title; //正文默认格式为html message.Body = body; message.IsBodyHtml = true; message.BodyEncoding = encoding; message.SubjectEncoding = encoding; client.Send(message); return true; } catch { return false; } } } } | |
本站网友 张明明 | 18分钟前 发表 |
mailDisaplyame | |
本站网友 appletviewer | 3分钟前 发表 |
mailServer); } public bool SendWebMail(string mailSenderAddress | |
本站网友 南亚热带植物园 | 17分钟前 发表 |
mailDisaplyame | |
本站网友 黑色档案 | 8分钟前 发表 |
string mailAccount | |
本站网友 内窥镜除皱 | 29分钟前 发表 |
C#.net用QQ服务邮箱发邮件2 using System; using System.Collecti.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Mail; namespace PowerOff { public partial class 邮件发送 | |
本站网友 洪刚 | 30分钟前 发表 |
string body | |
本站网友 前列腺图片 | 8分钟前 发表 |
邮件标题 | |
本站网友 德州启德大酒店 | 7分钟前 发表 |
mailtoAssress | |
本站网友 水榭花城 | 8分钟前 发表 |
mailto); message.Subject = title; //正文默认格式为html message.Body = body; message.IsBodyHtml = true; message.BodyEncoding = encoding; message.SubjectEncoding = encoding; client.Send(message); return true; } catch { return false; } } } } |