Set "Received" field for inbox item programmatically

  • Thread starter Thread starter Dhananjay
  • Start date Start date
D

Dhananjay

Hi All,
I am creating a inbox item programmatically in vb 2005/Office 2007/
VSTO. I want to set the "Received" field of that inbox item. How
should I do?

Thanks,
Dhananjay
 
Do you mean the ReceivedTime property?
It corresponds to the PR_MESSAGE_DELIVERY_TIME MAPI property and can be set
using Extended MAPI, CDO 1.21 or Redemption.
Outlook Object Model provides read-only access to that property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Do you mean the ReceivedTime property?
It corresponds to the PR_MESSAGE_DELIVERY_TIME MAPI property and can be set
using Extended MAPI, CDO 1.21 or Redemption.
Outlook Object Model provides read-only access to that property.

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









- Show quoted text -

Thank you Dmitry!
Let me ask you one question - if I found in my inbox mail "received"
is having value "Wed 10/24/2007 7:22PM", I can see my
PR_Message_Delivery_time property is having other value . So is it
depend on users system time or anything else?
 
Hi Dmitry,
Unfortunately my code is not working. I added following line to change
the received time. Other fields are changed successfully. But when I
see in the inbox Received time is same as my system time. In the
DateReceived variable I am getting the value as - "7/11/2007 1:22
AM" (I am fetching this value from XML file), which is previous than
my current system time. Any thing else should I change?
' Code snippet for changing the value of "Received".
Const PR_SENDER_EMAIL_ADDRESS% = &HC1F001E
Const PR_SENDER_NAME% = &HC1A001E
Const PR_SENT_REPRESENTING_EMAIL_ADDRESS% =
&H65001E
.fields(PR_SENDER_EMAIL_ADDRESS) = "(e-mail address removed)"
.fields(PR_SENDER_NAME) = "(e-mail address removed)"
.fields(PR_SENT_REPRESENTING_EMAIL_ADDRESS) =
"(e-mail address removed)"

--------->>> .Fields(&HE060040) = DateReceived '
PR_MESSAGE_DELIVERY_TIME

Thanks again
 
How exactly do you call that code? Are you setting the properties using
SafeMailItem.Fields or RDOMail.Fields?
In the former case the item is still saved by Outlook; and it might
overwrite the value set using Redemption when MailItem.Save is called.

The following script will create a sent item in the Inbox and set the Sender
and ReceivedTime properties using the RDO family of objects (which does not
depend on Outlook Object Model in any way):

set Session = CreateObject("Redemption.RDOSession")
'Session.Logon - if you do not use the line below
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set NewMsg =
Session.GetDefaultFolder(olFolderInbox).Items.Add("IPM.Note")
NewMsg.Sent = true
NewMsg.Subject = "fake sent item"
NewMsg.Body = "test body"
set Recip = NewMsg.Recipients.Add("(e-mail address removed)")
Recip.Resolve
NewMsg.Sender = Session.CurrentUser
NewMsg.SentOnBehalfOf = Session.CurrentUser
NewMsg.SentOn = Now
NewMsg.ReceivedTime = Now
NewMsg.Save

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