나는 C#에서 sourceforge의 "Koolwired.Imap"이라는 오픈 소스 프로젝트를 사용하여이 작업을 시도했습니다.C#의 IMAP - 메일 및 첨부 파일 다운로드
메일을 다운로드 할 때도 문제가 없지만 첨부 파일의 경우 첨부 파일의 파일 이름 만 나열됩니다. 이것을 시도한 사람이 있습니까?
동일한 기능을 수행 할 수있는 다른 더 좋은 무료 라이브러리 (내 캠퍼스 프로젝트를 위해이 일을하고 있기 때문에 나는이에 대한 무료/오픈 소스 솔루션이 필요합니다)
이ImapConnect connection = new ImapConnect("imap.gmail.com", 993, true);
ImapCommand command = new ImapCommand(connection);
ImapAuthenticate auth = new ImapAuthenticate(connection, "<username>@gmail.com", "<password>");
connection.Open();
auth.Login();
string htmlbody = "";
ImapMailbox mailbox = command.Select("INBOX");
mailbox = command.Fetch(mailbox);
int mailCount = mailbox.Messages.Count;
for (int i = 0; i < mailCount ; i++)
{
ImapMailboxMessage msg = mailbox.Messages[mailCount - 1];
msg = command.FetchBodyStructure(msg);
msg.BodyParts[0].ContentEncoding = BodyPartEncoding.NONE;
msg = command.FetchBodyPart(msg, msg.HTML);
foreach (ImapMessageBodyPart a in msg.BodyParts)
{
if (a.Data != null)
{
string fileName = "";
if (a.Attachment) fileName = ParseFileName(a.Disposition);
string mimeType = a.ContentType.MediaType.ToLower();
a.ContentEncoding = BodyPartEncoding.UTF7;
htmlbody = a.Data;
}
}
}
auth.Logout();
connection.Close();
그리고 사람들과 세부 정보를 공유하지 마십시오. –
테스트 계정입니다. 문제가 없습니다 .. –
어떻게이 코드를 실행할 수 있습니까? Gmail 계정에서만 메일을 다운로드 할 수 있습니까? 다운로드 후 다운로드 한 파일을 변환 할 수 있습니까? – Nicholas