Resolve email id's and unresolved email id's get them into an excel.

Hi,

Resolve email id's and unresolved email id's get them into an excel.
Below is a working code that gets the unresolved names to a txt file
can i get the data into an excel as

ColumA    ColumB
Name  Resolved/Unresolved

So i can filer and copy as required later

Regards
Sharath
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("D:\Unresolved Addresses.txt", True)
    For Each olkRecipient In Outlook.ActiveInspector.CurrentItem.Recipients
        If Not olkRecipient.Resolved Then
            objFile.WriteLine olkRecipient.Name
        End If
    Next
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    Set olkRecipient = Nothing
    MsgBox "Done"
End Sub

Open in new window

LVL 11
bsharathAsked:
Who is Participating?
 
David LeeConnect With a Mentor Commented:
Sharath,

This should do it.
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.csv", True)
    For Each olkRecipient In Outlook.ActiveInspector.CurrentItem.Recipients
        If olkRecipient.Resolved Then
            objFile.WriteLine Chr(34) & olkRecipient.Name & """,""Resolved"""
        Else
            objFile.WriteLine Chr(34) & olkRecipient.Name & """,""Unresolved"""
        End If
    Next
    objFile.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    Set olkRecipient = Nothing
    MsgBox "Done"
End Sub

Open in new window

0
 
bsharathAuthor Commented:
Thanks David worked perfect...
0
 
David LeeCommented:
You're welcome.
0
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.