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 2010 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:

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

Bruce Johnson

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
Thread starter Similar threads Forum Replies Date
Aussie Looking for Outlook macro to Copy Recipient Names into Email Body Outlook VBA and Custom Forms 3
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
L Looking for help - want to try an alternative to Outlook? Outlook Wishlist 0
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
U Looking for a person/company that we can PAY for Outlook 2003 tech service Using Outlook 0
T I am looking for a Microsoft Outlook Email Stationery download? Using Outlook 5
P Looking for Christmas Theme (thmx file) Using Outlook 5
D Microsoft Outlook not operating and is clouded looking Using Outlook 1
B Outlook 2007 at odd times shuts down then states it is looking for problem then starts up again Using Outlook 1
S Outlook 2003 (when looking at emails shows my name and not who sent the emails) Using Outlook 2
W "Looking for credential tiles..." when connecting to Exchange 2007 Using Outlook 4
S Outlook wont load - looking for microsoft exchange Using Outlook 1
M I am looking for support options for taskmanager in 2010 Using Outlook 1
P Looking for suggestions regarding a multi-site high availability/disaster resistant design Exchange Server Administration 1
S Looking for feedback on this CAS Array testing plan Exchange Server Administration 2
R Complicated mixed exchange environment, looking to move to 2010! Exchange Server Administration 8
A Microsoft Outlook cannot open - it's looking for a connection Using Outlook 2
C Looking for Collaboration / Communication Tools Using Outlook 4
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
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
Similar threads


















































Top