1、设置邮件的pop3

以163网易邮箱为例:

https://jingyan.baidu.com/article/adc81513804be9f722bf7350.html

2、下载OpenPop.dll

官网下载地址:http://sourceforge.net/projects/hpop/

3、读取设置pop3邮箱的所有邮件内容:

 public class Pop3Helper
{
public static void ReadPop3()
{
using (Pop3Client client = new Pop3Client())
{
if (client.Connected)
{
client.Disconnect();
} // Connect to the server, false means don't use ssl
client.Connect("pop3.163.com", , false); // Authenticate ourselves towards the server by email account and password
client.Authenticate("xxx@163.com", "pop3授权码"); //email count
int messageCount = client.GetMessageCount(); for (int i = ; i <= messageCount; i++)
{
Message message = client.GetMessage(i); NameValueCollection customHeaders = message.Headers.UnknownHeaders;
string sender = message.Headers.From.DisplayName;
string from = message.Headers.From.Address;
string subject = message.Headers.Subject;
DateTime Datesent = message.Headers.DateSent; MessagePart messagePart = message.MessagePart; GetCustomInfo(customHeaders); //email body
string body = " ";
if (messagePart.IsText)
{
body = messagePart.GetBodyAsText();
}
else if (messagePart.IsMultiPart)
{
MessagePart plainTextPart = message.FindFirstPlainTextVersion();
MessagePart htmlTextPart = message.FindFirstHtmlVersion();
if (htmlTextPart != null)
{ body = htmlTextPart.GetBodyAsText();
} if (plainTextPart != null)
{ body = plainTextPart.GetBodyAsText();
}
else
{
List<MessagePart> textVersions = message.FindAllTextVersions();
if (textVersions.Count >= )
body = textVersions[].GetBodyAsText();
else
body = "<<OpenPop>> Cannot find a text version body in this message.";
}
} } }
} //获取自定义字段内容
private static void GetCustomInfo(NameValueCollection col)
{
if (col != null && col.Count > )
{
foreach (var cHeaderKey in col.AllKeys)
{
switch (cHeaderKey)
{
case "X-CamId":
Console.WriteLine(string.Format("CamId:{0}", col[cHeaderKey]));
break;
case "X-SubId":
Console.WriteLine(string.Format("SubId:{0}", col[cHeaderKey]));
break;
case "X-UserId":
Console.WriteLine(string.Format("UserId:{0}", col[cHeaderKey]));
break;
default:
break;
} } }
}
}

使用OpenPop.dll开发读取POP3邮件程序的更多相关文章

  1. 使用C#和OpenPop.dll开发读取POP3邮件程序

    制作一个ASP.NET MVC4论坛项目,该项目需要将以往十多年的Mail List(邮件列表)内容都导入到新的论坛中,因此需要能够将邮件的标题.发布时间.发布人及邮件内容导入到论坛的数据库内..Ne ...

  2. C#邮件接收系统核心代码(接收POP3邮件IMAP邮件)

    /* * Created by SharpDevelop. * User: Administrator * Date: 2013/11/18 * Time: 20:55 * * To change t ...

  3. 无法启动此程序,因为计算机中丢失AdbWinApi.dll。尝试重新安装该程序以解决此问题

    第一次搭建android开发环境,装完adb以后,打开DOS验证安装是否成功:但输入adb logcat调试时,系统弹出以下异常的对话框: 无法启动此程序,因为计算机中丢失AdbWinApi.dll. ...

  4. 使用VS Code 开发.NET Core 应用程序 部署到Linux 跨平台

    使用VS Code 开发.NET Core 应用程序 部署到Linux 跨平台. 前面讲解了VSCode开发调试 .NET Core.都只是在windows下运行. .NET Core真正的核心是跨平 ...

  5. 开发安全的Web程序

    目录0x1:什么是安全的Web应用程序0x2:过滤输入的数据0x3:转义输出的数据0x4:Register Globals0x5:magic_quotes_gpc0x6:错误信息的报告0x7:文件的安 ...

  6. NET Core开发-读取配置文件Configuration

    ASP.NET Core开发-读取配置文件Configuration   ASP.NET Core 是如何读取配置文件,今天我们来学习. ASP.NET Core的配置系统已经和之前版本的ASP.NE ...

  7. 部署到Linux使用VS Code 开发.NET Core 应用程序

    使用VS Code 开发.NET Core 应用程序 部署到Linux 跨平台 使用VS Code 开发.NET Core 应用程序 部署到Linux 跨平台. 前面讲解了VSCode开发调试 .NE ...

  8. 【实验手册】使用Visual Studio Code 开发.NET Core应用程序

    .NET Core with Visual Studio Code 目录 概述... 2 先决条件... 2 练习1: 安装和配置.NET Core以及Visual Studio Code 扩展... ...

  9. Unity用Excel.dll简单读取Excel内容

    Unity用Excel.dll简单读取Excel内容 需要Excel.dll 需要如下三个命名空间 using System.IO; using Excel; using System.Data; 1 ...

随机推荐

  1. 【Teradata】变更viewpoint web登录地址

    1.使用root用户登录原viewpoint地址 ssh root@192.168.253.133 2.查看使用网卡(示例中为eth0) route Kernel IP routing table D ...

  2. PostgreSQL:Java使用CopyManager实现客户端文件COPY导入

    在MySQL中,可以使用LOAD DATA INFILE和LOAD DATA LOCAL INFILE两种方式导入文本文件中的数据到数据库表中,速度非常快.其中LOAD DATA INFILE使用的文 ...

  3. 使用superlance插件增强supervisor的监控能力

    supervisor与superlance简介 supervisor是一款用python编写的进程监控.进程守护和进程管理的工具,可以工作在各种UNIX-like的操作系统上,通过简单的配置就可以启动 ...

  4. 27 python 初学(信号量、条件变量、同步条件、队列)

    参考博客: www.cnblogs.com/yuanchenqi/articles/5733873.html  semaphore 信号量: condition 条件变量: event 同步条件:条件 ...

  5. go笔记-pprof使用

    go tool pprof http://localhost:6060/debug/pprof/profile go tool pprof http://localhost:6060/debug/pp ...

  6. BZOJ3711 Druzyny 最大值分治、线段树

    传送门 被暴力包菜了,然而还不会卡-- 有一个很暴力的DP:设\(f_i\)表示给\(1\)到\(i\)分好组最多可以分多少组,转移枚举最后一个组.接下来考虑优化这个暴力. 考虑:对于每一个位置\(i ...

  7. 获取任意链接文章正文 API 功能简介

    此文章对开放数据接口 API 之「获取任意链接文章正文」进行了功能介绍.使用场景介绍以及调用方法的说明,供用户在使用数据接口时参考之用. 1. 产品功能 接口开放了根据提供的文章链接 Url 参数,智 ...

  8. (hdu 6024) Building Shops

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6024 Problem Description HDU’s n classrooms are on a ...

  9. 【转】IT行业岗位以及发展方向

    以下转自https://blog.csdn.net/qq_23994787/article/details/79847270 职业生涯规划的意义 1.以既有的成就为基础,确立人生的方向,提供奋斗的策略 ...

  10. php中一些容易混淆的函数总结

    在我们日常PHP开发中,经常会使用一些函数完成相关操作,但是有些函数功能相近,很容易混淆,再次总结一下 1. __DIR__  &&  getcwd() 看官方解释: getcwd: ...