VBScript Please Help. How do I Retrieve the Send on Behalf of EmailAddress?

S

Shawn

Hi,

I have been searching for hours how to do this, but I just find posts
about people setting the send on behalf email address for sending
emails, but can't find how to retrieve the send on behalf email
address from a received email.

I am using a vbscript to retrieve email data off of my exchange
server. I
have noticed that some emails show that they are sent on behalf of
another user. For example, I get PayPal payment emails that say
something like (e-mail address removed); on behalf of; (e-mail address removed).
The headers of these email addresses usually show this snippet of
info:
From: <[email protected]>
Sender: <[email protected]>


When I try to retrieve the name and email address with my script
(using ObjMess.Sender.Name and ObjMess.Sender.Address) it always
shows
the PayPal (e-mail address removed) email address but never the send on
behalf email address that I also need. Would anyone be so kind and
friendly as to tell me what I need to add to my code below to also
display the Send on Behalf of Email address and User Name?


Public Sub ShowUndreadMessages(server, mailbox)


Dim objSess, objInbox, objMsgColl
Dim objMess
dim wsh : Set wsh= CreateObject( "WScript.Shell" )


Set objSess = CreateObject("MAPI.Session")


strProfileInfo = server & vbLf & mailbox
objSess.Logon "", "", True, True, , False, strProfileInfo


Set objInbox = objSess.Inbox
If objInbox Is Nothing Then
MsgBox "Invalid IPM Inbox from session"
Exit Sub
End If


Set objMsgColl = objInbox.Messages ' get Inbox’s messages
collection ' ( ... then validate the messages collection before
proceeding ... )


For Each objMess in objMsgColl ' performs loop, Sets each objMess


Wscript.Echo ObjMess.Sender.Name & vbTab & ObjMess.Sender.Address


Next ' even easier than objMsgColl.GetFirst and .GetNext


objSess.Logoff


Set objSess = Nothing
Set objInbox = Nothing
Set objMsgColl = Nothing
Set objMess = Nothing
set wsh=nothing
End Sub


ShowUndreadMessages "exchangeserver","mailbox"


Thanks in Advance!
Shawn
 

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