none
Automate Checking of "Show this folder as an e-mail Address Book" RRS feed

  • Question

  • Hello,

    We have ~1000 poeple we are bringing online with Office 365 (Plan E3).  The issue we are facing is that the users are not able to find their address books listed under "My Contacts" when they compose a new email and click on "To:...".  We found that checking the "Show this folder as an e-mail Address Book" by following these steps resolves our issue: Right click on "Contacts" -> Click Properties..." -> Click "Outlook Address Book" -> Check the box "Show this folder as an e-mail Address Book".  Can someone take a look at this script I found as it's throwing an error Run-time error '424': Object required? When I click "Debug" it shows If (tempfolder.DefaultItemType = 2) Then being the issue.

    This would be best as many of the users have 10+ folders under "My Contacts".

     I am not familier with VB scripting but here is the code I found online:

    Sub NewTest()

    Dim aFolders, fldr, i, j, objNS, FolderPath

    rootFolder = "Public Folders\All Public Folders\Contacts"


    Set objNS = GetObject("", "Outlook.Application").GetNamespace("MAPI")
    aFolders = Split(rootFolder, "\")

    On Error Resume Next
    Set fldr = objNS.Folders(aFolders(0))
    If Err Then WScript.Quit
    For i = 1 To UBound(aFolders)
      Set fldr = fldr.Folders(aFolders(i))
      If Err Then WScript.Quit
    Next
    On Error GoTo 0

    'here 'fldr' contains your starting 'rootFolder' object, now enum all subfolders in there:

    EnumSubFolders fldr         'call recursive function for this folder
    Set objNS = Nothing


    End Sub
    Function EnumSubFolders(tempfolder)

        'folder types: 0 = mail; 1 = calendar; 2 = contacts; 3 = tasks; 4 = journal; 5 = notes

        If (tempfolder.DefaultItemType = 2) Then

            tempfolder.ShowAsOutlookAB = True 'mark current folder as mail address book

        End If

        If tempfolder.Folders.Count Then 'if there are several subfolders in here

            For j = 1 To tempfolder.Folders.Count

                EnumSubFolders tempfolder.Folders(j) 'call same function again for each subfolder

            Next

        End If

    End Function

    Thanks,

    Sachin

    Wednesday, November 14, 2012 8:54 PM

Answers

  • so, just to be sure: you want code that will check this property on 'Suggested Contacts' folder in your screenshot?

    if so, simply call EnumSubFolders (objNS.DefaultStore.Folders("Suggested Contacts"))

    Saturday, November 17, 2012 8:29 PM
  • so, you want to grab all top-level contacts folders? use something like this (pseudo code):

    for each folder in objNS.DefaultStore.Folders

    if(folder.DefaultItemType == 2)

        EnumSubFolders(folder)

    end if

    next

    Sunday, November 18, 2012 12:02 PM

All replies

  • are you sure that:

    'here 'fldr' contains your starting 'rootFolder' object, now enum all subfolders in there:

    EnumSubFolders fldr 'call recursive function for this folder

    'fldr' contains 'root folder'? from what i see in your script it should already be set to 'Contacts' folder , assuming that it exists. Please add additional check at the start of EnumSubFolders if passed tempfolder parameter is not null. Also in outlook 2010 name of root folder in public folders changed to contain also your store's email address - maybe this is your issue? show us screenshot of your publlic folder structure that you see in outlook.

    Thursday, November 15, 2012 8:00 AM
  • Hi DamianD,

    Thank you for your reply.  Here is a screen shot of the folder in my "Contacts" tab and you are also correct that the location contains my email address.  I have also attached a screen shot of the properties.

    For rootFolder, I have tried to assign the location few different ways but it shows as "Empty" when I debug.  Here are the assignments I have tried.

    rootFolder = "Contacts"

    rootFolder = "Public Folders\All Public Folders\Contacts"

    rootFolder = "Contacts\Sachin"


    One more thing, I just tried \\Sachin.xxxx@xxxx.com as rootFolder.
    • Edited by aarvind1 Friday, November 16, 2012 12:44 AM
    Friday, November 16, 2012 12:40 AM
  • what you show us here is screenshot of your normal contacts folder, not the one from public folders. Please show us screenshot of your public folders library.

    Friday, November 16, 2012 9:18 AM
  • Hi DamianD,

    Sorry, I am new to Outlook.  Last time I used Outlook was in 2003.  Anyway, I don't think I have personal folders.  I clicked on the little folder icon at the bottom and took a screen shot. If I had it, my understanding is that it would be here.  If I am not looking in the right place, can you please let me know how to get this?  Also, we are using the cloud version of Office 365 maybe that's the reason.

    Friday, November 16, 2012 11:25 PM
  • so, just to be sure: you want code that will check this property on 'Suggested Contacts' folder in your screenshot?

    if so, simply call EnumSubFolders (objNS.DefaultStore.Folders("Suggested Contacts"))

    Saturday, November 17, 2012 8:29 PM
  • almost corrrect.  Because I won't know how many folders the user might have or the names I would need to find that out first then recursively check the property on each of the folders.  We have about 1000 users that I need to accomplish this for.

    So from my screen shot as an example, I would need first find out what address books folders exist then check the property for each one.

    For some sort of query that tells me I have Information Technology (ab_admin), Novell GroupWise Address Book, Sachin.

    Then, I can use your suggestion to call EnumSubFolders (objNS.DefaultStore.Folders(walkthroughlistofFolders)).

    Saturday, November 17, 2012 8:44 PM
  • so, you want to grab all top-level contacts folders? use something like this (pseudo code):

    for each folder in objNS.DefaultStore.Folders

    if(folder.DefaultItemType == 2)

        EnumSubFolders(folder)

    end if

    next

    Sunday, November 18, 2012 12:02 PM