C# 如何通过ipworks获取文档
ipworks库提供了一些获取文本消息的方法C# 如何通过ipworks获取文档,c#,email,parsing,imap,ipworks,C#,Email,Parsing,Imap,Ipworks,ipworks库提供了一些获取文本消息的方法 在文档中,我找不到如何使用imaps通过ipworks库阅读附件。我为/n软件工作,我们在这里遇到了您的问题。根据这个问题的标签,您可能正在使用我们的.NET版本和C代码,因此我将使用C代码作为示例 从Imaps组件检索附件需要使用MessageParts属性。此属性包含下载的电子邮件中各个MIME部分的集合。通常,前两部分是电子邮件的HTML正文(如果适用)和电子邮件的纯文本正文。任何附件都将在剩余的MIME部分中。您可以使用以下类似的代码从所选电
在文档中,我找不到如何使用imaps通过ipworks库阅读附件。我为/n软件工作,我们在这里遇到了您的问题。根据这个问题的标签,您可能正在使用我们的.NET版本和C代码,因此我将使用C代码作为示例 从Imaps组件检索附件需要使用MessageParts属性。此属性包含下载的电子邮件中各个MIME部分的集合。通常,前两部分是电子邮件的HTML正文(如果适用)和电子邮件的纯文本正文。任何附件都将在剩余的MIME部分中。您可以使用以下类似的代码从所选电子邮件中检索附件:
Imaps imap = new Imaps();
imap.OnSSLServerAuthentication += new Imaps.OnSSLServerAuthenticationHandler(delegate(object sender, ImapsSSLServerAuthenticationEventArgs e)
{
//Since this is a test, just accept any certificate presented.
e.Accept = true;
});
imap.MailServer = "your.mailserver.com";
imap.User = "user";
imap.Password = "password";
imap.Connect();
imap.Mailbox = "INBOX";
imap.SelectMailbox();
imap.MessageSet = "X"; //Replace "X" with the message number/id for which you wish to retrieve attachments.
imap.FetchMessageInfo();
for (int i = 0; i < imap.MessageParts.Count; i++)
{
if (imap.MessageParts[i].Filename != "")
{
//The MessagePart Filename is not an empty-string so this is an attachment
//Set LocalFile to the destination, in this case we are saving the attachment
//in the C:\Test folder with its original filename.
//Note: If LocalFile is set to an empty-string the attachment will be available
// through the MessageText property.
imap.LocalFile = "C:\\Test\\" + imap.MessageParts[i].Filename;
//Retrieve the actual attachment and save it to the location specified in LocalFile.
imap.FetchMessagePart(imap.MessageParts[i].Id);
}
}
imap.Disconnect();
电子邮件也可能包含嵌套的MIME结构。这是一个更复杂的情况,需要使用递归方法来解构嵌套的MIME结构。我们的MIME组件(在我们的IP*Works和IP*Works S/MIME产品中提供)对此非常有用
如果您需要另一种语言的示例,处理嵌套MIME结构的示例,或者如果您有任何其他问题,请随时联系我们support@nsoftware.com.你试过什么吗?我试过FetchMessages()和FetchInfo()方法。最后属性MessageContentEncoding为空。非常感谢。我知道了,是的,是C。
imap.AutoDecodeParts = true;
imap.FetchMessageInfo();