rchambers
asked on
Find contacts within Outlook 2010 groups
Hi
I've seen from existing questions that it was not possible to search for contacts within groups at Outlook 2007 or earlier. Has this been introduced at 2010, or does anyone have a quick script which will help? It's not in my default contacts folder, it's for the contacts folder of a shared mailbox.
Thanks
I've seen from existing questions that it was not possible to search for contacts within groups at Outlook 2007 or earlier. Has this been introduced at 2010, or does anyone have a quick script which will help? It's not in my default contacts folder, it's for the contacts folder of a shared mailbox.
Thanks
ASKER
Contact groups. I.e. what were distribution lists.
Ok. Are we talking about a personal contact group (i.e. one that you create in Outlook) or a group on an Exchange server (i.e. one that was created by your email admin)? Also, what do you need to know once a match is found in a group?
ASKER
It's a contacts folder belonging to a shared mailbox, full of contact groups that are maintained by users of that folder, not email admins.
I want to be able to find out which groups a particular email address is in, but ideally that would extend to any string (I might know a name but not an email for example). I then know which groups I have to edit.
I want to be able to find out which groups a particular email address is in, but ideally that would extend to any string (I might know a name but not an email for example). I then know which groups I have to edit.
Ok. This should do it. The code below will search all the groups in the currently selected folder, the folder must be a contacts folder, for the string you enter. If it finds that string in any of the groups, then it will display a dialog-box showing the name(s) of the groups it is in. The search looks at both the name and email address. Right now the search is case sensitive, but I can change that if necessary.
Follow these instruction to add the code to Outlook.
1. Start Outlook
2. Press ALT+F11 to open the Visual Basic editor
3. If not already expanded, expand Microsoft Office Outlook Objects
4. If not already expanded, expand Modules
5. Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7. Click the diskette icon on the toolbar to save the changes
8. Close the VB Editor
To use the code
1. Select a folder containing contacts.
2. Run the macro.
3. Enter a name, email address, or portion of either to search for.
Follow these instruction to add the code to Outlook.
1. Start Outlook
2. Press ALT+F11 to open the Visual Basic editor
3. If not already expanded, expand Microsoft Office Outlook Objects
4. If not already expanded, expand Modules
5. Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7. Click the diskette icon on the toolbar to save the changes
8. Close the VB Editor
Sub FindInGroup()
Const MACRO_NAME = "Find in Group"
Dim strFin As String, strHit As String, olkFol As Outlook.MAPIFolder, olkItm As Object, olkLst As Outlook.DistListItem, olkRec As Outlook.RECIPIENT
strFin = InputBox("Enter the string to search for.", MACRO_NAME)
If strFin <> "" Then
Set olkFol = Application.ActiveExplorer.CurrentFolder
If olkFol.DefaultItemType = olContactItem Then
For Each olkItm In olkFol.Items
If olkItm.Class = olDistributionList Then
Set olkLst = olkItm
For intCnt = 1 To olkLst.MemberCount
Set olkRec = olkLst.GetMember(intCnt)
If (InStr(1, olkRec.Address, strFin) > 0) Or (InStr(1, olkRec.Name, strFin) > 0) Then
strHit = strHit & vbCrLf & olkLst.Subject
Exit For
End If
Next
End If
Next
If Len(strHit) > 0 Then
MsgBox "The following groups contain the string " & strFin & vbCrLf & vbCrLf & strHit, vbInformation + vbOKOnly, MACRO_NAME
Else
MsgBox "The string " & strFin & " was not found in any groups in this folder.", vbInformation + vbOKOnly, MACRO_NAME
End If
Else
MsgBox "You must select a folder containing contacts before running this macro.", vbCritical + vbOKOnly, MACRO_NAME
End If
Else
MsgBox "You did not enter anything tos earch for. Operation cancelled.", vbInformation + vbOKOnly, MACRO_NAME
End If
End Sub
To use the code
1. Select a folder containing contacts.
2. Run the macro.
3. Enter a name, email address, or portion of either to search for.
ASKER
Okay so this gives me a list in a message box of all the groups that have a contact in. But I then need to look up each one in the Outlook explorer window. Also the message box size is restricted.
Is it possible to filter the current view by the search result? Allowing me to click into each one in turn to amend the members?
Is it possible to filter the current view by the search result? Allowing me to click into each one in turn to amend the members?
Is it possible to filter the current view by the search result?
No, that's not possible. If that were possible, then you'd be able to do this by constructing a search in Outlook. There'd be no need to use code to do this.
Okay so this gives me a list in a message box of all the groups that have a contact in. But I then need to look up each one in the Outlook explorer window. Also the message box size is restricted.
I can present the results in a different way that will allow you to click on the item and open it. You hadn't mentioned you wanted this capability in your original question, which is why I took the approach I did.
No, that's not possible. If that were possible, then you'd be able to do this by constructing a search in Outlook. There'd be no need to use code to do this.
Okay so this gives me a list in a message box of all the groups that have a contact in. But I then need to look up each one in the Outlook explorer window. Also the message box size is restricted.
I can present the results in a different way that will allow you to click on the item and open it. You hadn't mentioned you wanted this capability in your original question, which is why I took the approach I did.
ASKER
Hi thanks, no you're right I didn't mention this because the question I was asking was about using search, which would give me the results in the list and thus would have standard item functionality, so I didn't really think about how it would be presented alternatively.
I'm surprised this isn't a standard function, I can't be alone in wanting this. In fact I've seen reference to it having once been an available feature, I don't know how true that is.
I'm surprised this isn't a standard function, I can't be alone in wanting this. In fact I've seen reference to it having once been an available feature, I don't know how true that is.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi, my IT dept have sorted the missing protocol handler now and this works a treat - many thanks.
It really ought to be a built-in feature though!
It really ought to be a built-in feature though!
You're welcome.
You know, a better solution would be a search and replace. That would save you from having to open each group and manually make the change.
You know, a better solution would be a search and replace. That would save you from having to open each group and manually make the change.
ASKER
Agreed but that's a level of complexity I don't really need. This is fine, and in fact it's already helped me find groups with email addresses in which I had no idea were related.
Thanks again.
Thanks again.
I'm not clear on what you mean by "groups". Can you explain a bit more?