none
Change default folders in contacts and add a contact!? RRS feed

  • Question

  • Hi!

    I can create a "newFolder" under contacts so far so good :-)

    I can read the Folders with  get "Folders".... so i become all Folders under contacts...

    Now i will write in my "newFolder" a new contact...

    But i can only write in the Default Folder... :-(

    How can i Change form the Default contact Folder to my own Folder "newFolder" so that i can write a new contact in this Folder?

    Best Regards

    Bernd

    Wednesday, February 18, 2015 1:35 PM

Answers

  • How are you creating the contact? Are you using Application.CreateItem (which will use the default folder) or MAPIFolder.Items.Add? Note that even in the latter case the Big Brother Outlook might still create the item in the default folder (it knows best, right?). You can explicitly move the item to the right folder using ContactItem.Move (returns the new ContactItem object).

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

    • Marked as answer by Bernd Riemke Wednesday, February 18, 2015 4:14 PM
    Wednesday, February 18, 2015 2:41 PM

All replies

  • Hello Bernd,

    You can use the Parent property of the default folder to access the parent folder object and add your own folder there.

    The Namespace class provides the Stores property which returns a Stores collection object that represents all the Store objects in the current profile. The Store class provides the GetDefaultFolder method which returns a Folder object that represents the default folder in the store and that is of the type specified by the FolderType argument. This method is similar to the GetDefaultFolder method of the NameSpace object. The difference is that this method gets the default folder on the delivery store that is associated with the account, whereas NameSpace.GetDefaultFolder returns the default folder on the default store for the current profile. Also you may find the GetRootFolder method helpful.

    Be aware, the Add method of the Folders class accepts two parameters. The second one allows to specify the type of the folder (in your case should be paased olFolderContacts).

    Finally, you may find the How To: Create a new folder in Outlook and How To: Create a new Outlook Contact item programmatically articles helpful.


    Wednesday, February 18, 2015 1:48 PM
  • Hi!

    Have you a short code sample for the writing in "myNewFolder" with MAPI not .NET

    in  C# or VB...!?

    Best Regards

    Bernd

    Wednesday, February 18, 2015 1:57 PM
  • Take a look at the How To: Create a new folder in Outlook article.

    Microsoft doesn't recommend and doesn't support using Extended MAPI in managed applications. You may consider using any wrappers around that API, or use it on your own risk (it works like a charm). Because if you meet any issue nobody can help you.


    Wednesday, February 18, 2015 2:13 PM
  • How are you creating the contact? Are you using Application.CreateItem (which will use the default folder) or MAPIFolder.Items.Add? Note that even in the latter case the Big Brother Outlook might still create the item in the default folder (it knows best, right?). You can explicitly move the item to the right folder using ContactItem.Move (returns the new ContactItem object).

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

    • Marked as answer by Bernd Riemke Wednesday, February 18, 2015 4:14 PM
    Wednesday, February 18, 2015 2:41 PM
  • Her is what i do:

    1. GetDefaultFolder... (Result: Contact Folder) = MyStandardContactFolder     --> OK!

    2. MyStandardContactFolder (Items) = Items from the "Contact Folder"  --> OK!

    3. MyStandardContactFolder "GetFolders" = MyContactFolders   --> OK!

    4. MyContactFolders "getItem" = AllMyFoldersFromContacts   --> OK!

    5. MyContactFolders "Add" = MyOwnNewFolder   --> OK!

    The Result is OK!

    - "Contact"

    - "My New Folder"

    - ....

    So the "Add" ist adding a New Folder to the Contatcs it is not a SubFolder under "Contacts"

    If it paralle with "contacts"... see 4 lines upper...

    Now i will add or read the "My New Folder" Folder...

    Wednesday, February 18, 2015 4:01 PM
  • Thats it !

    I Need the "MOVE" to bring the contact in the right Folder!

    Many Thanks!

    Best Regards

    Bernd

    Wednesday, February 18, 2015 4:13 PM