LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

基于LumiSoft.Net.dll发、收、删邮件

admin
2017年9月30日 17:15 本文热度 6539

发邮件:

  1. using LumiSoft.Net.SMTP.Client;  
  2.   
  3.   
  4. Mime m = new Mime();  
  5. MimeEntity mainEntity = m.MainEntity;  
  6. // Force to create From: header field  
  7. mainEntity.From = new AddressList();  
  8. mainEntity.From.Add(new MailboxAddress(txtFrom.Text, txtFrom.Text));  
  9.  // Force to create To: header field  
  10.  mainEntity.To = new AddressList();  
  11.  mainEntity.To.Add(new MailboxAddress(txtTo.Text, txtTo.Text));  
  12. mainEntity.Subject = txtSubject.Text;  
  13. //添加正文  
  14. mainEntity.ContentType = MediaType_enum.Multipart_mixed;  
  15. MimeEntity textEntity = mainEntity.ChildEntities.Add();  
  16. textEntity.ContentType = MediaType_enum.Text_html;  
  17. textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;  
  18. textEntity.DataText = txtBody.Text;  
  19. //发送附件  
  20.   MimeEntity attachmentEntity = new MimeEntity();  
  21.   attachmentEntity.ContentType = MediaType_enum.Application_octet_stream;  
  22.   attachmentEntity.ContentDisposition = ContentDisposition_enum.Attachment;  
  23.   attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;  
  24.   attachmentEntity.ContentDisposition_FileName = "c:/test.jpg";  
  25.   attachmentEntity.DataFromFile("c:/test.jpg");  
  26.       
  27.   mainEntity.ChildEntities.Add(attachmentEntity);  
  28.       
  29.   SMTP_Client.QuickSend(m);  

收邮件:

  1. using LumiSoft.Net.POP3.Client;  
  2. using LumiSoft.Net;  
  3. using LumiSoft.Net.Mime;  
  1. public List<Mime> GetEmails(string pop3Server, string pop3Port, string username, string password)  
  2.         {  
  3.             bool pop3UseSsl = false;  
  4.             List<string> gotEmailIds = new List<string>();  
  5.             List<Mime> result = new List<Mime>();  
  6.             using (POP3_Client pop3 = new POP3_Client())  
  7.             {  
  8.                 try  
  9.                 {  
  10.                     pop3.Connect(pop3Server, Convert.ToInt32(pop3Port), pop3UseSsl);  
  11.                     pop3.Authenticate(username, password, false);  
  12.                     POP3_ClientMessageCollection infos = pop3.Messages;  
  13.                     foreach (POP3_ClientMessage info in infos)  
  14.                     {  
  15.                         if (gotEmailIds.Contains(info.UID))  
  16.                             continue;  
  17.                         byte[] bytes = info.MessageToByte();  
  18.                         gotEmailIds.Add(info.UID);  
  19.                         Mime mime = Mime.Parse(bytes);  
  20.                         result.Add(mime);  
  21.                     }  
  22.                 }  
  23.                 catch (Exception ex)  
  24.                 {  
  25.                     throw new Exception(ex.Message);  
  26.                 }  
  27.             }  
  28.             return result;  
  29.         }  

删除邮件:

  1. using LumiSoft.Net.POP3.Client;  
  2. using LumiSoft.Net;  
  3. using LumiSoft.Net.Mime;  
  1. private void DeleteMail()  
  2.         {  
  3.             using (POP3_Client c = new POP3_Client())  
  4.             {  
  5.                 c.Connect(pop3Server, Convert.ToInt32(pop3Port));  
  6.                 c.Authenticate(username, password, false);  
  7.                 if (c.Messages.Count > 0)  
  8.                 {  
  9.                     foreach (POP3_ClientMessage mail in c.Messages)  
  10.                     {  
  11.                         mail.MarkForDeletion();  
  12.                     }  
  13.                 }  
  14.             }  
  15.         }  

该文章在 2017/9/30 17:15:20 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved