Ed Salgado
Posts: 16
Joined: 2010-06-17
|
All,
I am having an interesting issue with deleted folders...
I have created a folder called "Special Inbox" that is on the same level as the main "Inbox". I can then go through the list of folders and find the my Special Inbox using the following code:
var
NameSpace: _NameSpace;
IFolders: Folders;
InboxParent: MapiFolder;
i: integer;
begin
NameSpace := OutlookApp.GetNamespace('MAPI');
IFolders := NameSpace.Folders;
InboxParent := OutlookApp.Session.Folders.Item(1);
SpecialInbox := nil;
for i := 1 to InboxParent.Folders.Count do
if InboxParent.Folders.Item(i).Name = SpecialInboxStr then
begin
SpecialInbox := InboxParent.Folders.Item(i);
Break;
end; { if... }
if SpecialInbox = nil then
begin
SpecialInbox := InboxParent.Folders.Add(SpecialInboxStr, olFolderInbox);
end else
ShowMessage ('Special Inbox found: ' + SpecialInbox.Name);
end;
So far so good... But here's the problem: If I permanently delete the "Special Inbox" and re-run the code above, it still finds the deleted inbox. I can even manually create a new "Special Inbox", but the code above still seems to be finding the deleted version if though it doesn't appear in the folder list in Outlook. I suspect there is some sort of caching mechanism that I am not aware of.
Is there any way I can modify the code above to see if the folder it finds actually exists and isn't deleted? I was hoping to see a DELETED property or some such, but I can't seem to figure out the magic code...
Thanks!
-ed |
|
Ed Salgado
Posts: 16
Joined: 2010-06-17
|
All,
Never mind... I changed the code to find the InboxParent from:
InboxParent := OutlookApp.Session.Folders.Item(1);
to
InboxParent := OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderInbox);
InboxParent := InboxParent.Parent as MapiFolder;
and all seems to be working. Do you see any issue with that?
Thanks!
-ed |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hi Ed,
The second variant looks better since it finds the Inbox in any of the stores available for the current Outlook profile.
I'd suggest that you use the code above (i.e. finding the folder by its name and location) when your add-in starts for the first time. You can get the EntryId of the folder and then use Namespace.GetFolderFromID to find your folder in any location choosen by the user.
Andrei Smolin
Add-in Express Team Leader |
|