博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LumiSoft.Net 收发邮件
阅读量:4312 次
发布时间:2019-06-06

本文共 5159 字,大约阅读时间需要 17 分钟。

一: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

源码下载地址:

 

User:     readonly
Password: readonly

二:收邮件

开发前需要引用LumiSoft.Net.dll文件,下载地址:

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)                        {                        }                    }                }            }        }    }}

 

转载于:https://www.cnblogs.com/sunyj/p/6733579.html

你可能感兴趣的文章
入门阶段
查看>>
学生信息管理系统应用ios源码iPad版
查看>>
Android中使用http协议访问网络
查看>>
ASP.NET Core 菜鸟之路:从Startup.cs说起
查看>>
vs win32 & MFC 指针默认位置
查看>>
Join 与 CountDownLatch 之间的区别
查看>>
js存cookie
查看>>
vc6下dll调试
查看>>
Ubuntu apt常用命令
查看>>
struts2 配置(部分)
查看>>
python代码迷之错误(ModuleNotFoundError: No module named 'caffe.proto')
查看>>
nodejs adm-zip 解压文件 中文文件名乱码 问题解决
查看>>
MapReduce-文本输入
查看>>
在Linux中简单实现回收子进程
查看>>
<Bootstrap> 学习笔记六. 栅格系统使用案例
查看>>
学习blus老师js(6)--js运动基础
查看>>
谈谈架构非功能性
查看>>
【timeisprecious】【JavaScript 】JavaScript RegExp 对象
查看>>
How to set colors of HTML tables
查看>>
Cannot parse POST parameters of request: '<URL>'
查看>>