email - How to apply filter on recent N Outlook.Items and get Outlook.Items after filtering? -


i want use following code filter out unread outlook mails,but want apply restriction on recent n outlook.items.but not find such method.

outlook.explorer currexplorer = null; outlook.folder currfolder = null; outlook.items folderitems = null; outlook.items restricteditems = null; outlook.mailitem mail = null; outlook.attachments attachments = null; int attachmentcount = 0;  try {      currexplorer = outlookapp.activeexplorer();     currfolder = currexplorer.currentfolder outlook.folder;     if (currfolder.defaultitemtype == outlook.olitemtype.olmailitem)     {         folderitems = currfolder.items;         restricteditems = folderitems.restrict("[unread]=true");           (int = 1; <= restricteditems.count; i++)         {             mail = restricteditems[i] outlook.mailitem;             if (mail != null)             {                 attachments = mail.attachments;                 attachmentcount += attachments.count;                 marshal.releasecomobject(attachments);                 marshal.releasecomobject(mail);             }         }      }  } 

you need use restrict method twice - first getting recent n items , second getting unread items between them. there no query n items in collection, can use time , time range filtering items, see enumerating, searching, , filtering items in folder more information.

you may find following articles helpful:


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -