A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Looping through and/or creating Exchange folders via Redemption



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 11th 07, 10:01 PM posted to microsoft.public.outlook.program_addins
Mike
external usenet poster
 
Posts: 332
Default Looping through and/or creating Exchange folders via Redemption

I need a way to loop through the folders in the current user's (Exchange)
mailbox. I will be searching in particular for a folder that I need to be
there, and if it is not, I need to create it. Is this possible through the
Redemption objects? If so, can anyone point me towards some sample code?
Thanks very much.

Ads
  #2  
Old October 12th 07, 01:25 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Looping through and/or creating Exchange folders via Redemption

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where RDOSrore is
returned by RDOSession.Stores colelection or RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's (Exchange)
mailbox. I will be searching in particular for a folder that I need to be
there, and if it is not, I need to create it. Is this possible through
the
Redemption objects? If so, can anyone point me towards some sample code?
Thanks very much.



  #3  
Old October 12th 07, 04:18 AM posted to microsoft.public.outlook.program_addins
Mike
external usenet poster
 
Posts: 332
Default Looping through and/or creating Exchange folders via Redemptio

Yes, based on name, and it seems easy enough I guess even without Redemption
code, but is it possible to add a folder on the same level as Inbox, i.e.,
att the Namespace level? Something like
Outlook._Namespace.Folders.Add("newfolder", ???) but what Object type to
give it? I've tried it with defaultInbox type, but get a generic "couldn't
complete the operation" Exception.

Is it even possible to add a folder at that level?

Folders.Add Method:
// TODO: Add code here to start the application.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oTasks =
olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks);
Outlook.Folders oFolders = oTasks.Folders;
Outlook.MAPIFolder oPersonalTasks = oFolders.Add("Personal
Tasks",Outlook.OlDefaultFolders.olFolderTasks);
Console.Write(oPersonalTasks.Name);

"Dmitry Streblechenko" wrote:

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where RDOSrore is
returned by RDOSession.Stores colelection or RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's (Exchange)
mailbox. I will be searching in particular for a folder that I need to be
there, and if it is not, I need to create it. Is this possible through
the
Redemption objects? If so, can anyone point me towards some sample code?
Thanks very much.




  #4  
Old October 12th 07, 07:30 AM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Looping through and/or creating Exchange folders via Redemptio

IN RDO that would be either
set Folder =
RDOSession.GetDefaultFolder(olFolderInbox).Parent. Folders.Add("Test Tasks",
olFolderTasks)
or
set Folder = RDOSession.Stores.DefaultStore.IPMRootFolder.Folde rs.Add("Test
Tasks", olFolderTasks)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Yes, based on name, and it seems easy enough I guess even without
Redemption
code, but is it possible to add a folder on the same level as Inbox, i.e.,
att the Namespace level? Something like
Outlook._Namespace.Folders.Add("newfolder", ???) but what Object type to
give it? I've tried it with defaultInbox type, but get a generic
"couldn't
complete the operation" Exception.

Is it even possible to add a folder at that level?

Folders.Add Method:
// TODO: Add code here to start the application.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oTasks =
olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks);
Outlook.Folders oFolders = oTasks.Folders;
Outlook.MAPIFolder oPersonalTasks = oFolders.Add("Personal
Tasks",Outlook.OlDefaultFolders.olFolderTasks);
Console.Write(oPersonalTasks.Name);

"Dmitry Streblechenko" wrote:

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where RDOSrore is
returned by RDOSession.Stores colelection or
RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's
(Exchange)
mailbox. I will be searching in particular for a folder that I need to
be
there, and if it is not, I need to create it. Is this possible through
the
Redemption objects? If so, can anyone point me towards some sample
code?
Thanks very much.






  #5  
Old October 12th 07, 05:34 PM posted to microsoft.public.outlook.program_addins
Mike
external usenet poster
 
Posts: 332
Default Looping through and/or creating Exchange folders via Redemptio

Last question, hopefully! Now that I am able to add the folder, is there any
way to associate a different icon with it? thanks for your help.

I finally got it to work with the following (seems you can't use the named
value from the OlDefaultFolders enum, you have to use an actual #)

Outlook._Application olApp = OutlookApp;
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
// adds to root level
olNs.Folders.Item(1).Folders.Add("Archive Search", 6);
//olNs.Folders.Item(1).Folders.Add("Test Folder",
Outlook.OlDefaultFolders.olFolderInbox);


"Dmitry Streblechenko" wrote:

IN RDO that would be either
set Folder =
RDOSession.GetDefaultFolder(olFolderInbox).Parent. Folders.Add("Test Tasks",
olFolderTasks)
or
set Folder = RDOSession.Stores.DefaultStore.IPMRootFolder.Folde rs.Add("Test
Tasks", olFolderTasks)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Yes, based on name, and it seems easy enough I guess even without
Redemption
code, but is it possible to add a folder on the same level as Inbox, i.e.,
att the Namespace level? Something like
Outlook._Namespace.Folders.Add("newfolder", ???) but what Object type to
give it? I've tried it with defaultInbox type, but get a generic
"couldn't
complete the operation" Exception.

Is it even possible to add a folder at that level?

Folders.Add Method:
// TODO: Add code here to start the application.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oTasks =
olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks);
Outlook.Folders oFolders = oTasks.Folders;
Outlook.MAPIFolder oPersonalTasks = oFolders.Add("Personal
Tasks",Outlook.OlDefaultFolders.olFolderTasks);
Console.Write(oPersonalTasks.Name);

"Dmitry Streblechenko" wrote:

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where RDOSrore is
returned by RDOSession.Stores colelection or
RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's
(Exchange)
mailbox. I will be searching in particular for a folder that I need to
be
there, and if it is not, I need to create it. Is this possible through
the
Redemption objects? If so, can anyone point me towards some sample
code?
Thanks very much.







  #6  
Old October 12th 07, 05:54 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Looping through and/or creating Exchange folders via Redemptio

No, the icon displayed by Outlook depends on whether the folder is one of
the default folders in the store or on the value of the PR_CONTAINER_CLASS
property.
Why can't you use one of the OlDefaultFolders enums? Do you get an error?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Last question, hopefully! Now that I am able to add the folder, is there
any
way to associate a different icon with it? thanks for your help.

I finally got it to work with the following (seems you can't use the named
value from the OlDefaultFolders enum, you have to use an actual #)

Outlook._Application olApp = OutlookApp;
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
// adds to root level
olNs.Folders.Item(1).Folders.Add("Archive Search", 6);
//olNs.Folders.Item(1).Folders.Add("Test Folder",
Outlook.OlDefaultFolders.olFolderInbox);


"Dmitry Streblechenko" wrote:

IN RDO that would be either
set Folder =
RDOSession.GetDefaultFolder(olFolderInbox).Parent. Folders.Add("Test
Tasks",
olFolderTasks)
or
set Folder =
RDOSession.Stores.DefaultStore.IPMRootFolder.Folde rs.Add("Test
Tasks", olFolderTasks)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Yes, based on name, and it seems easy enough I guess even without
Redemption
code, but is it possible to add a folder on the same level as Inbox,
i.e.,
att the Namespace level? Something like
Outlook._Namespace.Folders.Add("newfolder", ???) but what Object type
to
give it? I've tried it with defaultInbox type, but get a generic
"couldn't
complete the operation" Exception.

Is it even possible to add a folder at that level?

Folders.Add Method:
// TODO: Add code here to start the application.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oTasks =
olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks);
Outlook.Folders oFolders = oTasks.Folders;
Outlook.MAPIFolder oPersonalTasks = oFolders.Add("Personal
Tasks",Outlook.OlDefaultFolders.olFolderTasks);
Console.Write(oPersonalTasks.Name);

"Dmitry Streblechenko" wrote:

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where RDOSrore
is
returned by RDOSession.Stores colelection or
RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the
RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's
(Exchange)
mailbox. I will be searching in particular for a folder that I need
to
be
there, and if it is not, I need to create it. Is this possible
through
the
Redemption objects? If so, can anyone point me towards some sample
code?
Thanks very much.









  #7  
Old October 12th 07, 06:08 PM posted to microsoft.public.outlook.program_addins
Mike
external usenet poster
 
Posts: 332
Default Looping through and/or creating Exchange folders via Redemptio

You know, it's actually quite strange. An exception is thrown when using the
enum value, but the folder is actually still created. Didn't notice this at
first until I trapped the exception and bypassed it by mistake once, and
there was the folder. No exception is thrown when using a numeric value.
Here is the exception thrown when using the enum: (I see something regarding
permissions)

{System.__ComObject}
[System.__ComObject]: {System.__ComObject}
Application: {Outlook.ApplicationClass}
Class: olFolder
DefaultItemType: olMailItem
DefaultMessageClass: "IPM.Note"
Description: null
EntryID: (too long, i removed it from this text)
Folders: {Outlook.FoldersClass}
Items: {Outlook.ItemsClass}
Name: "Test Folder"
Parent: {System.__ComObject}
Session: {Outlook.NameSpaceClass}
StoreID: (too long, i removed it from this text)
UnReadItemCount: 0
UserPermissions: 'olNs.Folders.Item(1).Folders.Add("Test Folder",
Outlook.OlDefaultFolders.olFolderInbox).UserPermis sions' threw an exception
of type 'System.Runtime.InteropServices.COMException'
WebViewAllowNavigation: true
WebViewOn: false
WebViewURL: null



"Dmitry Streblechenko" wrote:

No, the icon displayed by Outlook depends on whether the folder is one of
the default folders in the store or on the value of the PR_CONTAINER_CLASS
property.
Why can't you use one of the OlDefaultFolders enums? Do you get an error?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Last question, hopefully! Now that I am able to add the folder, is there
any
way to associate a different icon with it? thanks for your help.

I finally got it to work with the following (seems you can't use the named
value from the OlDefaultFolders enum, you have to use an actual #)

Outlook._Application olApp = OutlookApp;
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
// adds to root level
olNs.Folders.Item(1).Folders.Add("Archive Search", 6);
//olNs.Folders.Item(1).Folders.Add("Test Folder",
Outlook.OlDefaultFolders.olFolderInbox);


"Dmitry Streblechenko" wrote:

IN RDO that would be either
set Folder =
RDOSession.GetDefaultFolder(olFolderInbox).Parent. Folders.Add("Test
Tasks",
olFolderTasks)
or
set Folder =
RDOSession.Stores.DefaultStore.IPMRootFolder.Folde rs.Add("Test
Tasks", olFolderTasks)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Yes, based on name, and it seems easy enough I guess even without
Redemption
code, but is it possible to add a folder on the same level as Inbox,
i.e.,
att the Namespace level? Something like
Outlook._Namespace.Folders.Add("newfolder", ???) but what Object type
to
give it? I've tried it with defaultInbox type, but get a generic
"couldn't
complete the operation" Exception.

Is it even possible to add a folder at that level?

Folders.Add Method:
// TODO: Add code here to start the application.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oTasks =
olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks);
Outlook.Folders oFolders = oTasks.Folders;
Outlook.MAPIFolder oPersonalTasks = oFolders.Add("Personal
Tasks",Outlook.OlDefaultFolders.olFolderTasks);
Console.Write(oPersonalTasks.Name);

"Dmitry Streblechenko" wrote:

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where RDOSrore
is
returned by RDOSession.Stores colelection or
RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the
RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's
(Exchange)
mailbox. I will be searching in particular for a folder that I need
to
be
there, and if it is not, I need to create it. Is this possible
through
the
Redemption objects? If so, can anyone point me towards some sample
code?
Thanks very much.










  #8  
Old October 12th 07, 07:28 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Looping through and/or creating Exchange folders via Redemptio

What is the COM exception number and message?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
You know, it's actually quite strange. An exception is thrown when using
the
enum value, but the folder is actually still created. Didn't notice this
at
first until I trapped the exception and bypassed it by mistake once, and
there was the folder. No exception is thrown when using a numeric value.
Here is the exception thrown when using the enum: (I see something
regarding
permissions)

{System.__ComObject}
[System.__ComObject]: {System.__ComObject}
Application: {Outlook.ApplicationClass}
Class: olFolder
DefaultItemType: olMailItem
DefaultMessageClass: "IPM.Note"
Description: null
EntryID: (too long, i removed it from this text)
Folders: {Outlook.FoldersClass}
Items: {Outlook.ItemsClass}
Name: "Test Folder"
Parent: {System.__ComObject}
Session: {Outlook.NameSpaceClass}
StoreID: (too long, i removed it from this text)
UnReadItemCount: 0
UserPermissions: 'olNs.Folders.Item(1).Folders.Add("Test Folder",
Outlook.OlDefaultFolders.olFolderInbox).UserPermis sions' threw an
exception
of type 'System.Runtime.InteropServices.COMException'
WebViewAllowNavigation: true
WebViewOn: false
WebViewURL: null



"Dmitry Streblechenko" wrote:

No, the icon displayed by Outlook depends on whether the folder is one of
the default folders in the store or on the value of the
PR_CONTAINER_CLASS
property.
Why can't you use one of the OlDefaultFolders enums? Do you get an error?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Last question, hopefully! Now that I am able to add the folder, is
there
any
way to associate a different icon with it? thanks for your help.

I finally got it to work with the following (seems you can't use the
named
value from the OlDefaultFolders enum, you have to use an actual #)

Outlook._Application olApp = OutlookApp;
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
// adds to root level
olNs.Folders.Item(1).Folders.Add("Archive Search", 6);
//olNs.Folders.Item(1).Folders.Add("Test Folder",
Outlook.OlDefaultFolders.olFolderInbox);


"Dmitry Streblechenko" wrote:

IN RDO that would be either
set Folder =
RDOSession.GetDefaultFolder(olFolderInbox).Parent. Folders.Add("Test
Tasks",
olFolderTasks)
or
set Folder =
RDOSession.Stores.DefaultStore.IPMRootFolder.Folde rs.Add("Test
Tasks", olFolderTasks)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
Yes, based on name, and it seems easy enough I guess even without
Redemption
code, but is it possible to add a folder on the same level as Inbox,
i.e.,
att the Namespace level? Something like
Outlook._Namespace.Folders.Add("newfolder", ???) but what Object
type
to
give it? I've tried it with defaultInbox type, but get a generic
"couldn't
complete the operation" Exception.

Is it even possible to add a folder at that level?

Folders.Add Method:
// TODO: Add code here to start the application.
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder oTasks =
olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderTasks);
Outlook.Folders oFolders = oTasks.Folders;
Outlook.MAPIFolder oPersonalTasks = oFolders.Add("Personal
Tasks",Outlook.OlDefaultFolders.olFolderTasks);
Console.Write(oPersonalTasks.Name);

"Dmitry Streblechenko" wrote:

Search in what sense? Based on name? Parent? Or...?
In general, you can start with RDOStore.IPMRootFolder (where
RDOSrore
is
returned by RDOSession.Stores colelection or
RDOSession.Stores.DefaultStore)
and recursively loop through all the subfolders of the
RDOFolder.Folders
collection.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Mike" wrote in message
...
I need a way to loop through the folders in the current user's
(Exchange)
mailbox. I will be searching in particular for a folder that I
need
to
be
there, and if it is not, I need to create it. Is this possible
through
the
Redemption objects? If so, can anyone point me towards some
sample
code?
Thanks very much.












 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redemption and Exchange Server issues j Add-ins for Outlook 3 July 17th 07 10:23 AM
Redemption and Exchange Server issues j Add-ins for Outlook 0 July 17th 07 09:22 AM
Redemption and Exchange Server issues j Add-ins for Outlook 0 July 17th 07 08:18 AM
Redemption and Exchange Server issues j Add-ins for Outlook 0 July 17th 07 08:17 AM
Creating a Calendar in Exchange 5.5 Public Folders...Rights error. Chris Stephens Outlook - Calandaring 1 May 4th 06 02:32 PM


All times are GMT +1. The time now is 09:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.