Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88030

Extract recipient from last item in sent mail folder in Outlook

$
0
0

I am trying to retrieve the recipient's name from the last e-mail sent from Outlook.

Using the Items.GetLast method returns the subject line, but I need the recipient's name.

I have tried looping through each item in the sent folder and extracting the information to a spreadsheet in Excel like this:

    For Each olMail In olFolder.Items
    For Each olRecipient In olMail.Recipients
        Cells(lngRow, 1) = olRecipient.Name
        Cells(lngRow, 2) = olRecipient.Address
    Next
    lngRow = lngRow + 1
Next
Else

The problem I run into is when there is a sent item that is not of an olMail type, such as a meeting request response. I end up getting a run-time error 13 Type mismatch.

For my purposes, I know that the last e-mail sent will always be the one that I need to get the recipient's name from, so it doesn't make a whole lot of sense to go through each item in the sent folder and grab the last one. Is there a way to return the last e-mail sent item and extract the recipient's name?

I will be executing this command from an Excel workbook.

Thanks.


Viewing all articles
Browse latest Browse all 88030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>