How do I retrieve CC email addresses from a mail in an Outlook folder using VBA?
I have this error
Run-time error '91':
Object variable or With block variable not set
Sub CC_EMAIL()
Dim lngCounter As Long
lngCounter = 2
Const PR_EMAIL = &H39FE001E
ThisWorkbook.Sheets(1).Cells(1, 1).Value = "CC Name"
ThisWorkbook.Sheets(1).Cells(1, 2).Value = "CC Email"
'ThisWorkbook.Sheets(1).Cells(1, 3).Value = "Cc-Recipients"
Set objOL = CreateObject("Outlook.Application")
Set objMsg = objOL.ActiveInspector.CurrentItem
Set objSmail = CreateObject("Redemption.SafeMailItem")
objSmail.Item = objMsg
For Each recip In objSmail.Recipients
If InStr(objSmail.CC, recip.Name) Then
ThisWorkbook.Sheets(1).Cells(lngCounter, 1).Value = recip.Name
ThisWorkbook.Sheets(1).Cells(lngCounter, 2).Value = recip.Fields(PR_EMAIL)
'ThisWorkbook.Sheets(1).Cells(lngCounter, 3).Value = objSmail.CC
lngCounter = lngCounter + 1
End If
Next
End Sub