system.net.Pop3从收件箱中读取电子邮件并下载

时间:2018-06-29 17:14:50

标签: c# asp.net email c#-4.0

我正在使用System.net.Pop3 dll。我想根据一些搜索条件来阅读电子邮件。我需要将此作为类库项目。

我有这个问题可以从主题,正文和抄送中读取。但是我无法获取附件计数并读取文件并将其保存在本地。这是代码

using System.Net.Pop3;
using Bp.BA; for mail properties reference
public class Pop
{
  Pop3Message msg= new Pop3Message();
public List<Pop3Message> ReadEmail(MailProperties s)
  Pop3Client s=new Pop3Client();
List<Pop3Message> lst=new List<Pop3Message>();
var email = s.GetEmailCount();
bool bln=false;
for(uint i=0;i<= email;i++)
{
if(s.GetMessage(i).From.Contains( s.email(i).From)
{
bln=true;
}
if(s.GetMessage(i).Subject.Contains( s.email(i).Subject)
{
bln=true;
}
if(bln)
{

string from = s.email(i).From;
string to = s.email(i).To;
string subject=s.email(i).Subject;
string [] attach= s.email(i).Attachment here attachment count is always 0.

lst.Add(s.GetEmail(i));

Download(msg(i).Attachmentlist(i));
}
}
public void Download(Pop3AttachmentList ms)
{
foreach(item in ms)
{
Filestream fs=new (

download file here.
}
}
}

0 个答案:

没有答案
相关问题