Reading Recipients in a folder

  • Thread starter Thread starter Neil Perry
  • Start date Start date
N

Neil Perry

Hi -

I am trying to extract all of the email addresses I have sent emails to in a
folder to a text file. So far I have been able to extract the email address
of the person who sent the email (i.e. me) using the SenderEmailAddress
property, but when I try to use the Recipients property, I get the error
"Run-time error '438': Object doesn't support this property or method."

The code I am using is:

Sub SetFlagIcon()
Dim myOlApp As Outlook.Application
Dim mpfInbox As Outlook.MAPIFolder
Dim obj As Outlook.MailItem
Dim i As Integer
Dim s As String
Dim sendername1 As String
Dim response As Integer

Set myOlApp = CreateObject("Outlook.Application")
Set mpfInbox =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Test")
' Loop all items in the Inbox\Test Folder
For i = 1 To mpfInbox.Items.Count
If mpfInbox.Items(i).Class = olMail Then
Set obj = mpfInbox.Items.Item(i)
s = obj.SenderEmailAddress
's = obj.Recipients
obj.Save
MyFile = "c:\nperry4\" & "nperry4.txt"
fnum = FreeFile()
Open MyFile For Append As fnum
Print #fnum, s
Close #fnum
End If
Next
End Sub

I have commented out the recipients line while I figure it out.

Many thanks for any response.
Neil
 
Recipients is a collection, not a string property:

Set recips = obj.Recipients
For Each recip in Recips
MsgBox recip.Address
Next
 
Back
Top