How can i sort or seperate resolved names and unresolved names from Outlook TO box.

Posted on 2009-04-18
Medium Priority
Last Modified: 2012-05-06

How can i sort or seperate resolved names and unresolved names from Outlook TO box.
I have say 600+ names that i pasted in the TO box of a new mail. There are a lot of names that have not got resolved. How can i just get those names seperated.

Any solution any way is fine for me. Just need to get the unresolved names seperated from the resolved names.

Exchange 2003 /Outlook 2007

Question by:bsharath
  • 4
  • 3
LVL 76

Expert Comment

by:David Lee
ID: 24176046
Hi, Sharath.

There is no way to separate them in the To field.  What do you want to do with the unresolved names?  Just identify them, remove them from the message, something else?
LVL 11

Author Comment

ID: 24176065
I want to get them to a txt or excel so i can see why they are not resolving
LVL 76

Accepted Solution

David Lee earned 2000 total points
ID: 24176102
This should do it.  Add the code to Outlook.  Create a message and enter the addressees.  Run the macro with the message still open.  It'll write all the unresolved addresses to a text file.
Sub GetUnresolved()
    Dim objFSO As Object, objFile As Object, olkRecipient As Outlook.Recipient
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Change the file name and path on the next line'
    Set objFile = objFSO.CreateTextFile("C:\eetesting\Unresolved Addresses.txt", True)
    For Each olkRecipient In Outlook.ActiveInspector.CurrentItem.Recipients
        If Not olkRecipient.Resolved Then
            objFile.WriteLine "Name: " & olkRecipient.Name & vbTab & "Address: " & olkRecipient.Address
        End If
    Set objFile = Nothing
    Set objFSO = Nothing
    Set olkRecipient = Nothing
    MsgBox "Done"
End Sub

Open in new window

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Author Comment

ID: 24176113
Thanks David this is Awsome help...

Was very useful at this time...

I get this
Name: Sharath rty Address:
Can i just get the name
LVL 76

Expert Comment

by:David Lee
ID: 24176130
Sure.  Change line #8 from

    objFile.WriteLine "Name: " & olkRecipient.Name & vbTab & "Address: " & olkRecipient.Address
to either

    objFile.WriteLine "Name: " & olkRecipient.Name


   objFile.WriteLine olkRecipient.Name

The former includes the literal "Name" the latter has just the name.
LVL 11

Author Comment

ID: 24176145
Thank U David....
LVL 76

Expert Comment

by:David Lee
ID: 24176179
You're welcome.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question