I need to access a folder called TEST, which is inside the inbox, with the following code I can access the messages in the inbox;
//Recupera todos los correos hasta un máximo de 90
public List<Correos> recuperarCorreos()
{
var servicio = realizarConexion();
List<Correos> correos = new List<Correos>();
// Vincula la carpeta Bandeja de entrada al objeto de servicio.
FolderId folderToAccess = new FolderId(WellKnownFolderName.Inbox, "***@***.es");
Folder inbox = Folder.Bind(servicio, folderToAccess);
ItemView view = new ItemView(90);
// Esta llamada a método da como resultado una llamada FindItem a EWS.
FindItemsResults<Item> findResults = servicio.FindItems(folderToAccess,view);
foreach (var correo in findResults)
{
var asuntoBase = "";//** SERVICE Nagios Test:
var remitente = correo.LastModifiedName;
var tiempoRecibido = correo.LastModifiedTime;
var asunto = correo.Subject;
String asunto2 = asunto.ToString();
Boolean esTest = asunto2.StartsWith(asuntoBase);
Correos c = new Correos(remitente, asunto,tiempoRecibido);
if (true)
correos.Add(c);
}
return correos;
}
But to access that subfolder (TEST) which in turn has other 4 subfolders I'm going crazy, the goal would be to access that folder TEST and their 4 children to read the emails.