展开全部
protected void SendSuccess()
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("test@gmail.com", "someone");//必须是提供smtp服务的邮件服务器
message.To.Add(new MailAddress("test@yahoo.com.cn"));
message.Subject = "测试邮件" ;
message.CC.Add(new MailAddress("test@126.com"));
message.Bcc.Add(new MailAddress("test@126.com"));
message.IsBodyHtml = true;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Body = "邮件发送测试";
message.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587); // 587;//Gmail使用的端口
client.Credentials = new System.Net.NetworkCredential("test@gmail.com", "password"); //这里是申请的邮箱和密码
client.EnableSsl = true; //必须经过ssl加密
try
{
client.Send(message);
Response.Write("邮件已经成功发送到" + message.To.ToString() + "<br>");
}
catch (Exception ee)
{
Response.Write(ee.Message + "<br>" /* + ee.InnerException.Message*/ );
}
}
收邮件
using LumiSoft.Net.POP3.Client;
using LumiSoft.Net.Mail;
……
public IList<Mail_Message> ReceiveMail()
{
IList<Mail_Message> mailList = new List<Mail_Message>();
using (POP3_Client client = new POP3_Client())
{
client.Connect("pop.gmail.com",995,true);
client.Authenticate("zw.seaman", "zw_seaman", false);
POP3_ClientMessageCollection coll = client.Messages;
for (int i = 0; i < coll.Count; i++)
{
POP3_ClientMessage message = coll[i];
Mail_Message mm = Mail_Message.ParseFromByte(coll[i].MessageToByte());
mailList.Add(mm);
}
}
return mailList;
}
protected void Page_Load(object sender, EventArgs e)
{
IList<Mail_Message> mailList = new ZMail.Mail().ReceiveMail();
foreach (Mail_Message mail in mailList)
{
StringBuilder sb = new StringBuilder();
sb.Append(mail.From.ToString()).Append(" 发送给 ");
sb.Append(mail.To.ToString()).Append("<br/>") ;
sb.Append(mail.Subject).Append("<br/>");
sb.Append(mail.BodyHtmlText).Append("<hr/>");
Response.Write(sb.ToString());
}
}
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("test@gmail.com", "someone");//必须是提供smtp服务的邮件服务器
message.To.Add(new MailAddress("test@yahoo.com.cn"));
message.Subject = "测试邮件" ;
message.CC.Add(new MailAddress("test@126.com"));
message.Bcc.Add(new MailAddress("test@126.com"));
message.IsBodyHtml = true;
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Body = "邮件发送测试";
message.Priority = System.Net.Mail.MailPriority.High;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587); // 587;//Gmail使用的端口
client.Credentials = new System.Net.NetworkCredential("test@gmail.com", "password"); //这里是申请的邮箱和密码
client.EnableSsl = true; //必须经过ssl加密
try
{
client.Send(message);
Response.Write("邮件已经成功发送到" + message.To.ToString() + "<br>");
}
catch (Exception ee)
{
Response.Write(ee.Message + "<br>" /* + ee.InnerException.Message*/ );
}
}
收邮件
using LumiSoft.Net.POP3.Client;
using LumiSoft.Net.Mail;
……
public IList<Mail_Message> ReceiveMail()
{
IList<Mail_Message> mailList = new List<Mail_Message>();
using (POP3_Client client = new POP3_Client())
{
client.Connect("pop.gmail.com",995,true);
client.Authenticate("zw.seaman", "zw_seaman", false);
POP3_ClientMessageCollection coll = client.Messages;
for (int i = 0; i < coll.Count; i++)
{
POP3_ClientMessage message = coll[i];
Mail_Message mm = Mail_Message.ParseFromByte(coll[i].MessageToByte());
mailList.Add(mm);
}
}
return mailList;
}
protected void Page_Load(object sender, EventArgs e)
{
IList<Mail_Message> mailList = new ZMail.Mail().ReceiveMail();
foreach (Mail_Message mail in mailList)
{
StringBuilder sb = new StringBuilder();
sb.Append(mail.From.ToString()).Append(" 发送给 ");
sb.Append(mail.To.ToString()).Append("<br/>") ;
sb.Append(mail.Subject).Append("<br/>");
sb.Append(mail.BodyHtmlText).Append("<hr/>");
Response.Write(sb.ToString());
}
}
摩杜云
2024-07-09 广告
2024-07-09 广告
判断一个java邮件推送公司的好坏,不只是看价格,还要考虑很多因素。建议可以多对比几个看看。您可以到摩杜云了解下。摩杜云成立于2019年,依托于公司多年技术沉淀和强大的云计算研发实力,面向全世界各个国家和地区、企业组织和个人开发者,提供全球...
点击进入详情页
本回答由摩杜云提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询