How do I get the folder name for the current item

Add-in Express™ Support Service
That's what is more important than anything else

How do I get the folder name for the current item
 
Julian Pointer


Guest


I need to get the folder name for the current ContactItem, AppointmentItem or TaskItem, how do I do this?

Here is smy AddInInitialize Code...

FCalendarItems := TItems.Create(nil);
FCalendarItems.ConnectTo(OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderCalendar).Items);
FCalendarItems.OnItemAdd := DoCalendarItemAdd;
FCalendarItems.OnItemChange := DoCalendarItemChange;


and the top of the event handler

procedure TAddInModule.DoContactItemAdd(ASender: TObject; const Item: IDispatch);
var
IContact: ContactItem;
begin

if Assigned(Item) then
begin
Item.QueryInterface(IID__ContactItem , IContact);
if Assigned(IContact) then
begin


How do I get the folder?

Posted 20 May, 2005 07:31:14 Top
Dmitry Kostochko


Add-in Express team


Posts: 2740
Joined: 2004-04-05
Hi Julian,

Try to use the ContactItem.Parent property.

Posted 20 May, 2005 08:39:51 Top
Julian Pointer




Posts: 3
Joined: 2005-05-21
Hi Dmitry,
Thanks... got it working, is there any way to attach to all folders, or all the contact folders? So instead of doing

FCalendarItems := TItems.Create(nil);
FCalendarItems.ConnectTo(OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderCalendar).Items);
FCalendarItems.OnItemAdd := DoCalendarItemAdd;
FCalendarItems.OnItemChange := DoCalendarItemChange;

something like...

FFolderItems := TItems.Create(nil);
FFolderItems.ConnectTo(OutlookApp.GetNamespace('MAPI').folders.Items);
FFolderItems.OnItemAdd := DoItemAdd;
FFolderItems.OnItemChange := DoItemChange;



Posted 21 May, 2005 02:18:55 Top
Dmitry Kostochko


Add-in Express team


Posts: 2740
Joined: 2004-04-05
Hi Julian,

You can iterate the Folders collection and attach to all folders you need. To determine the default Outlook item type contained in the folder see the MAPIFolder.DefaultItemType property.

Posted 21 May, 2005 04:28:05 Top
Julian Pointer




Posts: 3
Joined: 2005-05-21
thanks...
Posted 21 May, 2005 05:10:06 Top