DefaultItemType

Status
Not open for further replies.

aniruddh

New Member
Outlook version
Outlook 2010 32 bit
Email Account
hi there,

using C#
i have two list boxes. i want contact synchronization folder and email synchronization folder in list boexs.

i tried following code...

private void EnumerateFoldersInDefaultStore()
{
Outlook.Folder root = Application.Session.DefaultStore.GetRootFolder() as Outlook.Folder;
EnumerateFolders(root);
}

private void EnumerateFolders(Outlook.Folder folder)
{
Outlook.Folders childFolders = folder.Folders;
if (childFolders.Count > 0)
{
foreach (Outlook.Folder childFolder in childFolders)
{
EnumerateFolders(childFolder);
listBox1.Items.Add(childFolder.Name);
}
}
}

i want..

If the type == olMailItem than include in the 1st listbox

If the type == olContactItem than include in the 2nd listbox

how can i do this?
 
I recommend posting the tough questions in the MSDN forum - http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev (and anything with C# is tough. :))

But....

This line is getting the folders: listBox1.Items.Add(childFolder.Name);

So, you need to do an IF to select listbox1 or listbox2

If type == olMailItem then

listBox1.Items.Add(childFolder.Name);

If type == olContactItem then

listBox2.Items.Add(childFolder.Name);

you'll need end if or else/end if and proper code for C#, but it should work. If not, the guys in the MSDN forums are more experienced in C#.
 
Status
Not open for further replies.
Back
Top