Redemption to return the DisplayName or SenderName

B

bobdydd

Hi All

I am using the following code within Microsoft Access 2000 using
Redemption RDO and I am trying to get the following......They all work
except one........can anyone see why.

SenderEMail ' works OK
Creation_Time ' works OK
Body ' works OK
Subject ' works OK
SenderName ' DOES NOT WORK returns some obscure #

Can anyone see why



'Make declarations ans settings
' Keys ***********************
' MailItem1 = The Inbox itself
' MailItem2 = The First Item in the Inbox
Dim utils, _
MailItem1, _
MailItem2, _
Pr_Received_By_Name, Received_By_Name, _
PrSenderEmailAddress, SenderEMail, _
Pr_Creation_Time, Creation_Time, _
Pr_Subject, Subject, _
PR_SENDER_NAME, SenderName, _
Pr_Body, Body
Set utils = CreateObject("Redemption.MAPIUtils")
Set MailItem1 = Outlook.Session.GetDefaultFolder(olFolderInbox)
'Set the Inbox itself
'*****************************************************************************************


'fetch the email in the inbox's details
Set MailItem2 =
Outlook.Session.GetDefaultFolder(olFolderInbox).Items(1)
PrSenderEmailAddress = &HC1F001E
SenderEMail = utils.HrGetOneProp(MailItem2.MAPIOBJECT,
PrSenderEmailAddress)
'*****************************************************
Pr_Creation_Time = &H30070040
Creation_Time = utils.HrGetOneProp(MailItem2.MAPIOBJECT,
Pr_Creation_Time)
'*****************************************************
Pr_Body = &H1000001E
Body = utils.HrGetOneProp(MailItem2.MAPIOBJECT, Pr_Body)
'*****************************************************
Pr_Subject = &H37001E
Subject = utils.HrGetOneProp(MailItem2.MAPIOBJECT, Pr_Subject)
'*****************************************************
PR_SENDER_NAME = &H39FE001E
SenderName = utils.HrGetOneProp(MailItem2.MAPIOBJECT,
PR_SENDER_NAME)

Me.txtFrom = SenderEMail ' Enters "FROM" Field
Me.txtReceived = Creation_Time 'Enters the DATE SENT field
Me.txtContents = Body ' Enters "BODY" Field
Me.txtSubject = Subject ' Enters "SUBJECT" Field
Me.txtEmailDisplayName = PR_SENDER_NAME
 
K

Ken Slovak - [MVP - Outlook]

Me.txtEmailDisplayName = PR_SENDER_NAME

You're setting it equal to &H39FE001E.

If you're getting an Outlook session as Outlook.Session you really should
get a NameSpace object and Logon to it before using Session. Or just use a
NameSpace object. Also, once you have a NameSpace object you should do:

utils.MAPIOBJECT = oNameSpace.MAPIOBJECT

and when your code is finished don't forget to do:

utils.Cleanup

before setting it to Nothing.
 
D

Dmitry Streblechenko

What is that #? Is the property is not found, Redemption returns a variant
of type error; the error number will have the corresponding MAPI error code
(most likely MAPI_E_NOT_FOUND). That's probably what you are seeing.
Look at that particular message with MFCMAPI or OutlookSpy (click Imessage)
and make sure PR_SENDER_NAME is present. Also do check the type of the value
returned by HrGetOneProp.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Top