如何解决我使用 LumiSoft.Net 加载电子邮件附件 excel
private void loademail()
{
string UserName = "";
string Pwd = "";
POP3_Client pop3 = new POP3_Client();
pop3.Connect("smtp.gmail.com",587,false);
pop3.Login(UserName,Pwd);
POP3_ClientMessageCollection messages = pop3.Messages;
if (messages.Count <= 0)
{
return;
}
POP3_ClientMessage message = messages[0];
byte[] messageBytes = message.MessageToByte();
Mail_Message mime_message = Mail_Message.ParseFromByte(messageBytes);
MIME_Entity[] attachments = mime_message.GetAttachments(true,true);
foreach (MIME_Entity entity in attachments)
{
if (entity.ContentDisposition != null)
{
string fileName = entity.ContentDisposition.Param_FileName;
if (!string.IsNullOrEmpty(fileName))
{
DirectoryInfo dir = new DirectoryInfo(@"D:\email\");
if (!dir.Exists) dir.Create();
string path = Path.Combine(dir.FullName,fileName);
MIME_b_SinglepartBase byteObj = (MIME_b_SinglepartBase)entity.Body;
Stream decodedDataStream = byteObj.GetDataStream();
using (FileStream fs = new FileStream(path,FileMode.Create))
{
LumiSoft.Net.Net_Utils.StreamCopy(decodedDataStream,fs,4000);
}
}
}
}
message.MarkForDeletion();
pop3.Disconnect();
}
LumiSoft.Net 使用这个。
我想用C#来阅读这里的excel附件。我在这里出错
pop3.Connect("smtp.gmail.com",false);
获取消息:220 smtp.gmail.com ESMTP q23sm412689pfg.192 - gsmtp
怎么解决??
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。