使用OpenPop.Net收取邮件
2021-01-26 08:15
标签:net byte str version exce nec nts this using Nuget引用OpenPop.Net到项目中 支持POP3\IMAP协议, 使用OpenPop.Net收取邮件 标签:net byte str version exce nec nts this using 原文地址:https://www.cnblogs.com/lizhenhong/p/13231168.html Console.WriteLine("OpenPop.Pop3.Pop3Client:");
try
{
using (var client = new OpenPop.Pop3.Pop3Client())
{
client.Connect(host, port, false);
client.Authenticate(address, password);
var count = client.GetMessageCount();
for (int i = count; i > 0; i--)
{
OpenPop.Mime.Message message = client.GetMessage(i);
Console.WriteLine("Subject:" + message.Headers.Subject);
var messagePart = message.MessagePart;
string body = " ";
if (messagePart.IsText)
{
body = messagePart.GetBodyAsText();
}
else if (messagePart.IsMultiPart)
{
var plainTextPart = message.FindFirstPlainTextVersion();
if (plainTextPart != null)
{
body = plainTextPart.GetBodyAsText();
}
else
{
List
OpenPop.Pop3.Pop3Client对象连接服务器
host, port保证正确就能连接,
address, password保证正确就能登录