Bueno después de unos días de tocar el violín y la investigación en la red he descubierto:
FolderView fv = new FolderView(10);
var findFoldersResults = service.FindFolders(
WellKnownFolderName.Inbox,
new SearchFilter.SearchFilterCollection(
LogicalOperator.Or,
new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, "ERROR"), new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, "ARCHIVE")),
fv);
foreach (var folder in findFoldersResults)
{
if (folder is Folder)
{
if (folder.DisplayName.ToUpper() == "ARCHIVE")
{
archiveFolderID = folder.Id;
}
else if (folder.DisplayName.ToUpper() == "ERROR")
{
errorFolderID = folder.Id;
}
}
}
//if archive folder not found create and assign the variable to the folderID
if (archiveFolderID == null)
{
Folder folder = new Folder(service);
folder.DisplayName = "ARCHIVE";
folder.Save(WellKnownFolderName.Inbox);
archiveFolderID = folder.Id;
}
//if error folder not found create and assign the variable to the folderID
if (errorFolderID == null)
{
Folder folder = new Folder(service);
folder.DisplayName = "ERROR";
folder.Save(WellKnownFolderName.Inbox);
errorFolderID = folder.Id;
}
probablemente también se puede utilizar SearchFilter.IsEqualTo porque ContainsSubstring volverá carpetas con nombres como "NoERRORS" o "ERRORSNotAllowed" mientras que IsEqualTo usa == oparator, así que básicamente no tendrías que hacer tu propio 'if (folder.DisplayName.ToUpper() == "ERROR")' – grapkulec