Oliver Engst
Guest
|
Hi,
I'm doing my first steps in AddIn-Express. I searched the site but could not manage to find an example that allows me to find out how I can loop through all folders in all profiles to search within the mails, appointments and so on for specific conditions.
Is there an example for this kind of work?
Any help will be appreciated. |
|
Eugene Astafiev
Guest
|
Hi Oliver,
Unfortunately you can't loop through all folders in all profiles in your add-in project using the Outlook Object Model. Instead, you can use the following code to loop through all folders in the current profile:
Outlook.NameSpace ns = OutlookApp.GetNamespace("MAPI");
Outlook.Folders folders = ns.Folders;
for (int i = 1; i <= folders.Count; i++)
{
object index = i;
Outlook.MAPIFolder folder = folders.Item(index);
System.Windows.Forms.MessageBox.Show(folder.Name);
if (folder != null) Marshal.ReleaseComObject(folder);
// here you can loop trough all subfolders recursively
}
if (folders != null) Marshal.ReleaseComObject(folders);
if (ns != null) Marshal.ReleaseComObject(ns);
As a workaround you can try to use the http://www.add-in-express.com/products/mapi-store-events.php component to log into another Outlook profile and loop through all folders.
FYI To get assistance with host applications?Â?Ð?é objects, their properties, and methods as well as help info, use the Object Browser. Go to the VBA environment (in the host application, choose menu Tools | Macro | Visual Basic Editor or just press {Alt+F11}), press {F2}, select the host application in the topmost combo and/or specify a search string in the search combo. Select a class /property /method and press {F1} to get the help topic that relates to the object. |
|