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


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

LVL 11
Who is Participating?
David LeeConnect With a Mentor Commented:
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

David LeeCommented:
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?
bsharathAuthor Commented:
I want to get them to a txt or excel so i can see why they are not resolving
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

bsharathAuthor Commented:
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
David LeeCommented:
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.
bsharathAuthor Commented:
Thank U David....
David LeeCommented:
You're welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.