none
MailItem.Parent folder not giving desired folder name in Outlook with Different mail server other than Exchange RRS feed

  • Question

  • Hi,

    I am dragging and dropping an email from inbox to my custom folder under inbox. While dragging and dropping email I want to find my destination folder.

    I am using the below code.

    Outlook.MailItem mailItem = (Outlook.MailItem)item;

    Outlook.Folder parentFolder = mailItem.Parent as Outlook.Folder;

    This works fine if I have Outlook with Exchange Server. But If have some other mail server(eg. ArgoSoft Mail Server)

    it always returns "Inbox" as the folder name.

    Is there any way I can get the actual folder name where I am dropping my email from mailItem ?

    Wednesday, August 12, 2020 7:26 AM

All replies

  • Hello,

    Where and when do you check the Parent property of the Outlook item? Is it the ItemAdd event handler?

    Note, you can handle the Folder.BeforeItemMove event which is fired when an item is about to be moved or deleted from a folder, either as a result of user action or through program code. The folder parameter is passed as an argument which represents the folder to which the item is being moved.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, August 12, 2020 8:36 AM
  • Thank you for the response.

    Yes, I am using ItemAdd.

    If I use Folder.BeforeItemMove  I need to subscribe the event for each folder under the mail box.

    Is there any way I can subscribe it for whole mail box ? How can I identify whether event is triggered because of item delete or item move ?

    Wednesday, August 12, 2020 10:16 AM