PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: Junk email - how to access Reply-To or Return-Path?
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Re: Junk email - how to access Reply-To or Return-Path?
![]() |
Re: Junk email - how to access Reply-To or Return-Path? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
There is no Outlook property that returns the sender's email address. You can either use CDO (or Redemption to avoid security prompts -- http://www.dimastr.com/redemption/) to get the From address or use Outlook to get the Reply To address. Sample code at http://www.slipstick.com/dev/code/getsenderaddy.htm.
"Dave Bachmann" <nospam.dbachman@jmindspring.com> wrote in message news:eAYwPKmQDHA.2636@TK2MSFTNGP10.phx.gbl... > 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 > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

