Looking to get the Recipient email address (or even the "friendly name") from an email I am replying to using VBA

Status
Not open for further replies.

Bruce Johnson

Member
Outlook version
Outlook 2013 32 bit
Email Account
POP3
I am needing to get the email address that someone sent an email TO.
I have come up with one method that seems to use a link but that link is no longer valid:
Code:
  Const PR_SMTP_ADDRESS As String ="https://schemas.microsoft.com/mapi/proptag/0x39FE001E"
But I cannot find another way.

My immediate goal is to have a msgbox pop up with the email or the "friendly name" of the address the email was SENT to when I hit the REPLY ALL

Thanks!
Bruce
 
Last edited by a moderator:
I created the macros below from the macros on these two pages-
VBA Sample: Do Something When Reply is Clicked
Read MAPI properties not exposed in Outlook's Object Model

It displays the received by name (account name).

Code:
Option Explicit
Private WithEvents oExpl As Explorer
Private WithEvents oItem As MailItem
Private bDiscardEvents As Boolean
   Dim oResponse As MailItem
 
Private Sub Application_Startup()
   Set oExpl = Application.ActiveExplorer
   bDiscardEvents = False
End Sub
 
Private Sub oExpl_SelectionChange()
   On Error Resume Next
   Set oItem = oExpl.Selection.Item(1)
End Sub
 
' Reply
Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean)
   Cancel = True
   bDiscardEvents = True

Set oResponse = oItem.Reply
 afterReply
End Sub

' Forward
Private Sub oItem_Forward(ByVal Response As Object, Cancel As Boolean)
   Cancel = True
   bDiscardEvents = True

Set oResponse = oItem.Forward
 afterReply
End Sub

' Reply all
Private Sub oItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
   Cancel = True
   bDiscardEvents = True

Set oResponse = oItem.ReplyAll
 afterReply
End Sub

Private Sub afterReply()

Dim propertyAccessor As Outlook.propertyAccessor
Set propertyAccessor = oItem.propertyAccessor
Dim strPA As String
'PR_RECEIVED_BY_NAME
   strPA = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0040001E")
    oResponse.Display
  
MsgBox strPA

End Sub
 
Diane, thank so much! When it works, it is what I want (I can then build ifs or case statements once I find the results that I am looking for!) But, the issue is it seems that it will only work once or twice (or sometimes not at all) and then to get it to work, I need to restart outlook (And then is it may or may not work still...)
I have even put debug stops at the beginning of the
oItem_Reply
oItem_ReplyAll
afterReply
and it is not stoppong.
I am using 2013, and it does seem the REPLY and reply to ALL from the READING PANE is not supported, but I am hitting reply and reply all from the TOP menu (and sometimes it work and sometimes it does not)
At this point, I have your code and NO other in the ThisOutlooksession and it is NOT MODIFIED (anymore).

Any ideas?

Thanks! Bruce
 
REPLY and reply to ALL from the READING PANE is not supported,
I'll have to double check - i know it only works if the window pops out, but i thought it popped it out.

If something errors, it will stop working until you restart outlook or click Run when the cursor is it the application start up macro.

I have one that dies when it hits an error and use this attached to a ribbon button to restart it. Or to restart it anytime i think its might not be working. :)
Code:
Sub RunStart()
 Call Application_Startup
 MsgBox "App Start Started"
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Aussie Looking for Outlook macro to Copy Recipient Names into Email Body Outlook VBA and Custom Forms 3
sophievldn Looking for a macro that moves completed items from subfolders to other subfolder Outlook VBA and Custom Forms 7
C Looking for feedback on new Outlook Add-in Using Outlook 0
B Looking to filter (or just find/search) for only messages that the sender has sent more than 1 messa Using Outlook 2
G Looking for help with our Organization Forms Library Outlook VBA and Custom Forms 1
peacepanda How to save attachment looking at the attachment name Outlook VBA and Custom Forms 1
D Looking to move away from exchange to outlook.com Using Outlook 4
B Looking for Outlook 2013 update for Send Drafts Macro Using Outlook 4
M Looking for options and best practices for an Edge Server (Exchange or not) Exchange Server Administration 0
M Looking for trainer in Business Contact Manager BCM (Business Contact Manager) 0
O looking to bring in all my folders from Outlook Express (XP) to Outlook 2013 Using Outlook 3
B Looking for an add-in or a way to send automatic replies based off a list Using Outlook 2
R Outlook Template: Looking to distribute a VBA Outlook template to other people Using Outlook 1
J Looking for a solution (maybe an add-in) to easily track email conversations Using Outlook 3
I Looking for a productivity add-in similar to "Nostalgy" for Thunderbird Using Outlook 5
Q Looking for Outlook 2010 Close Event Id Exchange Server Administration 1
C Looking for way to tie a Business Contact to more than one Account BCM (Business Contact Manager) 5
J OL2003 Macro disables itself - looking for way to automate 'enable' Using Outlook 2
R Looking for my BCM backup files BCM (Business Contact Manager) 1
B Looking for email address under ItemSend event Outlook VBA and Custom Forms 6
S Looking for client-side method (Outlook 2007/Exchange 2007) for users to delete Outlook VBA and Custom Forms 2
S Looking for a Utility for Editting An Exported Rules (.rwz) File Using Outlook 6
P Outlook looking for Copy of Outlook.pst Outlook VBA and Custom Forms 1
U looking for feedback on installation process and on eMarking Assis Outlook VBA and Custom Forms 1
F Graphics in email / Mac recipient garbled Using Outlook 0
T Outlook 2010 recipient no longer shows in 'Send To' Using Outlook 0
S Adding a recipient's column to Sent folder in Outlook 2010 Outlook VBA and Custom Forms 1
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
C Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 4
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
K Use VBA to find Sender and Recipient from Microsfot 365 Journaled Email Items Outlook VBA and Custom Forms 3
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
T "Words In Recipient's Address" Rule Causes Outlook To Stop Processing Rules Using Outlook 3
M ERROR: None of your email accounts could send to this recipient Using Outlook 2
N Custom Form Controls Not Visible To Recipient Outlook VBA and Custom Forms 3
Daniel Schunk User-defined form arrives empty at the recipient Using Outlook 3
D Moving Emails Based on Recipient/Sender Outlook VBA and Custom Forms 4
J Signatures that contain recipient's email address Outlook VBA and Custom Forms 7
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
M recipient cache? Using Outlook 2
N Importing Google contacts from CSV file removes recipient names in autocomplete list Using Outlook 0
H How to show recipient email address? Using Outlook 0
R OL2010 - Send to Mail Recipient going to wrong account Using Outlook 1
J Searh For Recipient Email address Outlook VBA and Custom Forms 1
A Extracting only one recipient from Msgitem.To Outlook VBA and Custom Forms 7
Diane Poremsky Display the Recipient Email Address in the Sent Items Folder Using Outlook 0
E Meeting reminders are set for the recipient Exchange Server Administration 9
E Send a Reminder/Task to certain Email Recipient Using Outlook 5
B Recipient of a forwared message getting multiple emails Using Outlook 2

Similar threads

Back
Top