C# POP3、IMAP、SMTP收发邮件
2013-11-21 19:17
507 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Lesnikowski.Client; using Lesnikowski.Client.IMAP; using Lesnikowski.Mail; using Lesnikowski.Mail.Fluent; using Lesnikowski.Mail.Headers; using Lesnikowski.Mail.Headers.Constants; namespace Email { public class Class1 { public void POP3_Subject_Message(String User, String Password,String Server) { Pop3 pop3 = new Pop3(); pop3.Connect(Server); pop3.User = User; pop3.Password = Password; pop3.Login(); pop3.GetAccountStat(); SimpleMailMessageBuilder builder = new SimpleMailMessageBuilder(); for (int i = 1; i <= pop3.MessageCount; i++) { ISimpleMailMessage mail = builder.CreateFromEml(pop3.GetMessage(i)); Console.WriteLine(mail.Subject); } pop3.Close(true); } public void IMAP_Subject_Message(String User, String Password, String Server) { Imap imap = new Imap(); imap.Connect(Server); imap.User = User; imap.Password = Password; imap.Login(); imap.SelectInbox(); List<long> uidList = imap.SearchFlag(Flag.Unseen); foreach (long uid in uidList) { ISimpleMailMessage mail = new SimpleMailMessageBuilder() .CreateFromEml(imap.GetMessageByUID(uid)); Console.WriteLine(mail.Subject); } imap.Close(true); } public void SMTP_Send_Message(String User, String Password, String Server) { ISimpleMailMessage message = Mail .Html(@"Html with an image: <img src=""cid:lena"" />") .AddVisual(@"c:\lena.jpeg").SetContentId("lena") .AddAttachment(@"c:\tmp.doc").SetFileName("document.doc") .To("to@mail.com") .From("from@mail.com") .Subject("Subject") .Create(); Smtp smtp = new Smtp(); smtp.Connect(Server); smtp.Ehlo(HeloType.EhloHelo, "yourname"); smtp.User = User; smtp.Password = Password; smtp.Login(); smtp.SendMessage(message); smtp.Close(true); } } }
相关文章推荐
- c#中邮件收发处理(POP3,IMAP,SMTP)的实现方法
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- c#中邮件收发处理(POP3,IMAP,SMTP)
- vmime.NET 邮件收发类库 支持Smtp, Pop3, Imap,TLS and SSL
- [Email] 收发邮件的协议 : IMAP and SMTP , POP3 and SMTP
- 使用SMTP 和POP3 协议实现收发邮件(C/C++)
- indy的smtp和pop3收发邮件过程中怎样实现进度条
- 邮件协议POP3/IMAP/SMTP服务的区别
- 用SMTP,POP3访问Exchange邮箱进行内外网收发邮件
- 邮件收发原理(POP3/SMTP)
- 使用SMTP 和POP3 协议实现收发邮件(C/C++)
- 网易免费企业邮支持POP3/SMTP服务,您可以通过电脑客户端软件更好地收发邮件
- 邮件协议POP3/IMAP/SMTP服务的区别
- 邮件协议POP,POP3,SMTP,IMAP