I have the following code, in which I use the IMAP protocol that contains the S22.IMAP dll:
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();
}
.......
.......
}
}
}
}
but I have a problem, when I try to read the attachment of some mail, I realize in the debugging of the code that is not reading the attachment. The strange thing about this event is that it happens with some emails, as well as gmail and private emails (I do not say that all of these domains do not read the attachments), the others read them well.
I would like to know what would be the cause that prevents me from reading these emails. Could it be that there is some privacy settings, for example in gmail, to have it block the attachments in the code ?, and if it were true, how would you enable it? Or should I change the way the code is implemented? And what would be the best or some good example?
Of course, thank you, I hope your help please.