0
votes

I tried to delete contact item with my Outlook VSTO Add-In but the deleted contact item is moved to drafts folder instead of trash folder.

public void Delete(Outlook.ContactItem oco)
{
    if (oco != null)
    {
        privateInfo = oco.FullName;
        Outlook.NameSpace mapiNamespace = _Application.GetNamespace("MAPI");
        if (mapiNamespace != null)
        {
            Outlook.MAPIFolder trashFolder = mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
            if (trashFolder != null)
            {
                string folderpath = trashFolder.FolderPath  // to debug only
                oco.Move(trashFolder);
            }
        }
    }
}

The folderpath variable shows the right folder. I develop with Outlook 2016. I use Microsoft.Office.Iterop V15.0.4420.1017.

Who can explain this behavior?

Thanks

1
Are there any rules or VBA macro, or COM add-ins running in Outlook who could move an item to another folder?Eugene Astafiev

1 Answers

0
votes

I tried to delete contact item with my Outlook VSTO Add-In but the deleted contact item is moved to drafts folder instead of trash folder.

In the code you move an item passed as an argument to the Deleted Items folder. Use the ContactItem.Delete method which removes the item from the folder that contains the item. The Delete method moves the item from the containing folder to the Deleted Items folder. If the containing folder is the Deleted Items folder, the Delete method removes the item permanently.