Junk email - how to access Reply-To or Return-Path?

D

Dave Bachmann

I wrote the following macro to add selected emails to the junk senders list
and delete them all from a single button. Unfortunately, if the sender name
is just a name rather than an email address the junk mail filter doesn't
work properly. I've currently chosen not to add names other than those
containing valid email addresses, but I'd really like to access either the
Reply-To or Return-Path properties, but I can't seem to find them. Any
suggestions??


Sub FlagMailItemsAsJunk()
Dim oItem As Object
Dim oMailItem As Outlook.MailItem

Dim JUNK_SENDERS_FILE As String
Dim JunkName As String
JUNK_SENDERS_FILE = "C:\Windows\Application Data\Microsoft\Outlook\Junk
Senders.txt"

' Ensure that some items are selected!
If ActiveExplorer.Selection.Count > 1 Then
Open JUNK_SENDERS_FILE For Append As #1 ' Open file for output.

For Each oItem In ActiveExplorer.Selection
Select Case TypeName(oItem)
Case "MailItem"
Set oMailItem = oItem
JunkName = oMailItem.SenderName
' Only process names with a real address
If (InStr(JunkName, "@") > 0) Then
Print #1, JunkName
End If
oMailItem.UnRead = False
oMailItem.Delete
End Select
Next oItem

Close #1 ' Close file.
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top