一:LumiSoft.Net简介
Lumisoft is a software development company specialised in mobile phones and tablets. Our products make useful information available to mobile devices with a unique advantage: exceptional spee 源码下载地址:http://files.cnblogs.com/files/sunyj/LumiSoft.Net-master.zip
https://svn.lumisoft.ee:8443/svn/ |
二:收邮件
开发前需要引用LumiSoft.Net.dll文件,下载地址:http://files.cnblogs.com/files/sunyj/LumiSoft.Net.rar
using LumiSoft.Net; using LumiSoft.Net.Mail; using LumiSoft.Net.POP3.Client;using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WinPop3 { public partial class Form2 : Form { public Form2() { InitializeComponent(); using (POP3_Client c = new POP3_Client()) { //连接POP3服务器 c.Connect("pop3.163.com", WellKnownPorts.POP3); //验证用户身份 c.Login("********@163.com", "邮件密码/smtp、pop3授权码"); if (c.Messages.Count > 0) { //遍历收件箱里的每一封邮件 foreach (POP3_ClientMessage message in c.Messages) { try { //mail.MarkForDeletion(); //删除邮件 //收件人、发件人、主题、时间等等走在mime_header里获得 Mail_Message mime_header = Mail_Message.ParseFromByte(message.HeaderToByte()); //发件人 if (mime_header.From != null) { string displayname = mime_header.From[0].DisplayName; string from = mime_header.From[0].Address; } //收件人 if (mime_header.To != null) { StringBuilder sb = new StringBuilder(); foreach (Mail_t_Mailbox recipient in mime_header.To.Mailboxes) { string displayname = recipient.DisplayName; string address = recipient.Address; if (!string.IsNullOrEmpty(displayname)) { sb.AppendFormat("{0}({1});", displayname, address); } else { sb.AppendFormat("{0};", address); } } } //抄送 if (mime_header.Cc != null) { StringBuilder sb = new StringBuilder(); foreach (Mail_t_Mailbox recipient in mime_header.Cc.Mailboxes) { string displayname = recipient.DisplayName; string address = recipient.Address; if (!string.IsNullOrEmpty(displayname)) { sb.AppendFormat("{0}({1});", displayname, address); } else { sb.AppendFormat("{0};", address); } } } //发送邮件时间 DateTime dateTime = mime_header.Date; string ContentID = mime_header.ContentID; string MessageID = mime_header.MessageID; string OrgMessageID = mime_header.OriginalMessageID; string Subject = mime_header.Subject; byte[] messageBytes = message.MessageToByte(); Mail_Message mime_message = Mail_Message.ParseFromByte(messageBytes); if (mime_message == null) { continue; } string Body = mime_message.BodyText; try { if (!string.IsNullOrEmpty(mime_message.BodyHtmlText)) { //邮件内容 string BodyHtml = mime_message.BodyHtmlText; } } catch { } } catch (Exception ex) { } } } } } } }