none
How to check folder type of current folder in outlook RRS feed

  • Question

  • HI All,

    My requirement is that I have to check if current folder is Draft folder or not.

    I can get current folder in following way :--

    MAPIFolder currentFolder = This_AddIn.Application.ActiveExplorer().CurrentFolder;

    But this MAPI folder does not have any property which can tell us whether it is draft folder or inbox or send items.

    One way of doing it is in following way :--

    Store currentStore = currentFolder.Store;

    MAPIFolder draftFolder = currentStore.GetDefaultFolder(OlDefaultFolders.olFolderDrafts);

    After that I can compare EntryID. But this approach will not work if client is using customized draft folder instead of using default draft folder.

    Can somebody please suggest the right way to get folder type of current selected folder.

    Thanks

    Dev

    Sunday, September 24, 2017 12:45 PM

Answers

  • You are right to compare the entry ids, but you need to do that using Namespace.CompareEntryIDs. There is no such thing gas a "customized  draft folder". It is the folder where draft emails are saved by default. GetDefaultFolder(olFolderDrafts) will return that folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, September 24, 2017 5:51 PM

All replies

  • You are right to compare the entry ids, but you need to do that using Namespace.CompareEntryIDs. There is no such thing gas a "customized  draft folder". It is the folder where draft emails are saved by default. GetDefaultFolder(olFolderDrafts) will return that folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, September 24, 2017 5:51 PM
  • Hi Dmitry,

    It is the folder where draft emails are saved by default. GetDefaultFolder(olFolderDrafts) will return that folder.

    The Items.Add method allows to add a new item to a specific folder avoiding the Drafts one.


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

    Sunday, September 24, 2017 8:57 PM
  • Does that make it a custom Drafts folder? User created messages (unless you click "New Items | Post in this folder") are created in the Drafts folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Sunday, September 24, 2017 9:18 PM
  • I suppose we both knows that a custom Drafts folder can't be made ;)

    In case of user created messages you are absolutely correct! 

    However, any software like add-ins, VBA scripts or standalone application may automate Outlook and create new messages programmatically. In that case ItemAdd will not be fired for the Drafts folder if other folder is chosen as a parent (Items.Add).


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

    Sunday, September 24, 2017 10:23 PM
  • Hello Eugene,

    Thanks a lot for your insight. I will take care of it in my development.

    Thanks

    Devendra

    Monday, September 25, 2017 3:54 AM