【发布时间】:2018-03-27 17:50:53
【问题描述】:
我使用S22.IMAP库如下:
using (ImapClient client = new ImapClient(imap, 993,
usuario, psw, AuthMethod.Login, true))
{
foreach (var uid in client.Search(SearchCondition.Unseen()))
{
var message = client.GetMessage(uid);
foreach (Attachment atc in message.Attachments)
{
if (System.IO.Path.GetExtension(atc.Name) == ".xml")
{
String archivoXML_texto = "";
byte[] allBytes = new byte[atc.ContentStream.Length];
int bytesRead = atc.ContentStream.Read(allBytes, 0, (int)atc.ContentStream.Length);
using (MemoryStream memory = new MemoryStream(allBytes))
{
StreamReader archivoXML = new StreamReader(memory);
archivoXML_texto = archivoXML.ReadToEnd();
archivoXML.Close();
memory.Dispose();
}
.......
.......
}
}
}
}
}
我有一个问题:当我尝试阅读一些邮件的附件时, 我在调试代码时意识到没有阅读附件。 这个事件的奇怪之处在于,它发生在一些电子邮件,以及 gmail 和私人电子邮件(我并不是说所有这些域都不阅读附件),其他人阅读它们很好。
问题:
我想知道阻止我阅读这些电子邮件的原因是什么。会不会有一些隐私设置,例如在 gmail 中使其阻止代码中的附件?
如果这是真的,您将如何启用它?还是应该改变代码的实现方式?
最好的例子是什么?
【问题讨论】:
-
在您投反对票之前,请编辑/批准您帖子的现有编辑,以便更好地解释您的问题。首先,
Title完全错误。它应该是Cannot red attachments using MailKit。继续前进对于您的问题,您的主要问题也有很多缺陷,无法在 cmets 中描述。据我所知,您使用的是ImapClient类,它是ImapX或 MailKit 的一部分`但是在您的情况下,它是MailKit,您应该至少在Tags中添加它。但是,要进行故障排除,请转到 here -
他没有使用 MailKit,他使用的是 S22.Imap。
-
IMAP 使编写任何此类隐私功能变得困难或不可能。客户端要么有权访问消息的所有部分,要么无权访问。但是,如果您使用某种脑损伤病毒防护工具,可能就是这样。
标签: c# asp.net imap attachment gmail-imap