J
Jim Carpenter
I am writing a COM Add-In for Outlook 2002 using C#:
try
{
Outlook.NameSpace ns = applicationObject.GetNamespace("MAPI");
Outlook.MAPIFolder inbox =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder deleted =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
Outlook.MailItem item = (Outlook.MailItem) inbox.Items[0];
item = item.Move(deleted);
}
catch (Exception e)
{
Debug.WriteLine("Exception: " + e.Message);
}
When I try and move an item from the Inbox to the Deleted Items
folder, the code works correctly. If I then move the item from the
Deleted Items folder back to the Inbox using the GUI and run the code
again, it fails with a COMException: "Can't move the items." on
MailItem.Move.
It seems like the GUI is locking the MailItem and preventing the
Add-In from accessing it.
Any help would be greatly appreciated?
Thanks,
Jim Carpenter
SRI International
try
{
Outlook.NameSpace ns = applicationObject.GetNamespace("MAPI");
Outlook.MAPIFolder inbox =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder deleted =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
Outlook.MailItem item = (Outlook.MailItem) inbox.Items[0];
item = item.Move(deleted);
}
catch (Exception e)
{
Debug.WriteLine("Exception: " + e.Message);
}
When I try and move an item from the Inbox to the Deleted Items
folder, the code works correctly. If I then move the item from the
Deleted Items folder back to the Inbox using the GUI and run the code
again, it fails with a COMException: "Can't move the items." on
MailItem.Move.
It seems like the GUI is locking the MailItem and preventing the
Add-In from accessing it.
Any help would be greatly appreciated?
Thanks,
Jim Carpenter
SRI International