c# Pop3Client获取邮件的数量

杰森龙 2015-03-05 11:06:10
public static int EmailCount()
{
int attachmentNo = 0;
Pop3Client pop3Client;
pop3Client = new Pop3Client();
try
{
pop3Client.Connect("server", 110, true);
pop3Client.Authenticate("user", "pwd");
int count = pop3Client.GetMessageCount();//获取邮件数量7
return count;
}
catch(Exception e)
{
return 0;
}
}

这样获取的count是不对的,和实际的邮件总数不一样,并且这个count一直在变小。
这个count是什么东西?

怎么去获取实际的邮件的总数呢?

我见POP3的命令有STAT可以获取邮件总数,这个怎么使用??

新人求教&……





...全文
687 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_3958 2018-12-11
  • 打赏
  • 举报
回复
引用 6 楼 橘子皮zzz 的回复:
[quote=引用 5 楼 qq_3958 的回复:]
Pop3Client 是获取的本地数据,也就是本地的邮件,如果你用的是Foxmail 获取邮件的话,你在设置,收邮件的服务器的时候,邮件类型你就得选择POP3,然后在收取邮件!
在启动程序的时候你才能获取到正确的邮件总数


Pop3Client 是获取的本地数据,也就是本地的邮件 这句啥意思??????[/quote]



例如电脑上装了Foxmail客户端! 每收取一次邮件,你获取到的邮件就都保存在本地了!
qq_3958 2018-12-11
  • 打赏
  • 举报
回复
例如电脑上装了Foxmail客户端! 每收取一次邮件,你获取到的邮件就都保存在本地了!
橘子皮... 2018-12-10
  • 打赏
  • 举报
回复
引用 5 楼 qq_3958 的回复:
Pop3Client 是获取的本地数据,也就是本地的邮件,如果你用的是Foxmail 获取邮件的话,你在设置,收邮件的服务器的时候,邮件类型你就得选择POP3,然后在收取邮件! 在启动程序的时候你才能获取到正确的邮件总数
Pop3Client 是获取的本地数据,也就是本地的邮件 这句啥意思??????
qq_3958 2018-12-10
  • 打赏
  • 举报
回复
Pop3Client 是获取的本地数据,也就是本地的邮件,如果你用的是Foxmail 获取邮件的话,你在设置,收邮件的服务器的时候,邮件类型你就得选择POP3,然后在收取邮件!
在启动程序的时候你才能获取到正确的邮件总数
橘子皮... 2018-12-10
  • 打赏
  • 举报
回复
还有我发现手动去163邮箱发信,发信时间居然是实际时间的提前1个小时,这是为什么啊,谁知道
橘子皮... 2018-12-10
  • 打赏
  • 举报
回复
引用 3 楼 Nielsen_Nie 的回复:
ChilkatDotNet4.dll 这个很好用。里面包含POP的功能,很稳定。建议使用。
看了下,ChilkatDotNet4这个还不错,但是貌似收费的???我看代码上写的30天免费?? 1:有破解版的么??? 2:还有获取信内容是不是用 email.GetAlternativeBody(0),貌似参数也可以用1,但是用1貌似很多信内容提取不出来,这个参数有什么意义 3:bundle = mailman.GetAllHeaders(1) 这个1是什么作用的 4:怎么获取邮件是否未读取还是已读取状态? 5:有的时候突然获取不到任何邮件,然后过会又恢复了,是什么情况?
杰森龙 2015-03-09
  • 打赏
  • 举报
回复
引用 3 楼 Nielsen_Nie 的回复:
ChilkatDotNet4.dll 这个很好用。里面包含POP的功能,很稳定。建议使用。
这个怎么用??? 搜到很少 求指教
Nielsen_Nie 2015-03-07
  • 打赏
  • 举报
回复
ChilkatDotNet4.dll 这个很好用。里面包含POP的功能,很稳定。建议使用。
杰森龙 2015-03-06
  • 打赏
  • 举报
回复
错误 4 “Authenticate”方法没有任何重载采用“0”个参数 E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 52 17 LG_DAL 错误 7 “OpenPop.Pop3.Pop3Client”不包含“List”的定义,并且找不到可接受类型为“OpenPop.Pop3.Pop3Client”的第一个参数的扩展方法“List”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 61 54 LG_DAL 错误 9 “OpenPop.Pop3.Pop3Client”不包含“Noop”的定义,并且找不到可接受类型为“OpenPop.Pop3.Pop3Client”的第一个参数的扩展方法“Noop”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 94 24 LG_DAL 错误 11 “OpenPop.Pop3.Pop3Client”不包含“Quit”的定义,并且找不到可接受类型为“OpenPop.Pop3.Pop3Client”的第一个参数的扩展方法“Quit”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 102 24 LG_DAL 错误 10 “OpenPop.Pop3.Pop3Client”不包含“Rset”的定义,并且找不到可接受类型为“OpenPop.Pop3.Pop3Client”的第一个参数的扩展方法“Rset”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 98 24 LG_DAL 错误 6 “OpenPop.Pop3.Pop3Client”不包含“Stat”的定义,并且找不到可接受类型为“OpenPop.Pop3.Pop3Client”的第一个参数的扩展方法“Stat”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 56 36 LG_DAL 错误 3 “OpenPop.Pop3.Pop3Client”不包含“Trace”的定义,并且找不到可接受类型为“OpenPop.Pop3.Pop3Client”的第一个参数的扩展方法“Trace”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 47 24 LG_DAL 错误 2 “OpenPop.Pop3.Pop3Client”不包含采用“5”个参数的构造函数 E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 39 40 LG_DAL 错误 12 命名空间“OpenPop.Pop3”中不存在类型或命名空间名称“Posp3Client”。是否缺少程序集引用? E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 110 30 LG_DAL 警告 8 声明了变量“err”,但从未使用过 E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\Ote.cs 63 46 LG_DAL 错误 5 未能找到类型或命名空间名称“Stat”(是否缺少 using 指令或程序集引用?) E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 56 17 LG_DAL 错误 1 无法将类型“int”隐式转换为“string” E:\后台相关\后台文件存储、分析相关\[0]项目\客户端\LG_GADMS\LG_DAL\MailDAL.cs 37 28 LG_DAL
Justin-Liu 2015-03-05
  • 打赏
  • 举报
回复
C# 开发的邮件服务器 Features supports pop3 smtp imap etc. supports ssl/tls for pop3, smtp and imap. supports multi mail vitural server, can bind multi domains. supports run as windows service, winform application with or without tray icon control. supports remote management using mailservermanager.exe supports mail recycle bin supports plugins using api interfaces Build and release download source code or use the releases i provided. if from source code you should run afterbuild.bat after build the solution successfuly then you get the debug or release version from application folder. Installation run MailServerLauncher.exe to install as windows service or just run as desktop application with or without tray icon. Configuration run MailServerManager.exe at the machine runs mailserver service or app. Connect to server press connect button from menu. type server localhost or 127.0.0.1 or leave it empty type username Administrator with case sensitive type password emtpy press ok to connect with saving or not Add virtual server type name and select storage api [your vitural server]>system>general, add dns servers for query mailto's domain mx record. [your vitural server]>system>services, enable smtp and pop3 services and set ipaddress binding with or without ssl/tls. the host name is required when set bindings. eg. bind smtp service to smtp.[your.domain] + IPAddress.Any [your vitural server]>system>service>relay, 'send email using DNS' and set at least a local ipaddress binding for email sending. the name of the binding here only a name,not mean domain. [your vitural server]>system>logging, enable logging for all services when something error you can see the details from 'Logs and Events' node [your vitural server]>domains, set email host domain, eg. if your email will be xyz@abc.com then the domain should be abc.domain, description is optional [your vitural server]>security, !!! important, add rules for your service to allow outside access like email client. eg. add a rule 'Smtp Allow All' for smtp service with ip allows between 0.0.0.0 to 255.255.255.255 to enable smtp service for outside access add 'Pop3 Allow All' and 'Rlay Allow All' like that too. [your vitural server]>filters, there are two types of filter named 'DnsBlackList' and 'VirusScan' its configurable by run it's executable from mail server install path. Domain name resolution Add smtp.[your.domain], pop3.[your.domain], imap.[your.domain] resolution to your server public ip address with A record or to your server domain with CNAME record. mx record is optional if [your.domain] has a A record.if not, you shoud add a mx record point to your server ip. Remote management to enable remote management you must add ACL to allow mail server managers connect from outside network. use MailServerAccessManager.exe to add management users or just use administrator. add rules to allow access from specific IPs or ip ranges The users here only for management cases.

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧