Can't get SentOn property value for item in "Sent Items" folder

G

Guest

Hi,

I'm trying to archive old emails based on their SentOn, ReceivedTime, or CreationTime properties. I can get the value for these properties for any item except the items in the "Sent Items" folder. E.g., when I try to get the SentOn time, I get an error.

ItemTime = MyItems(MyItems.Count).SentOn

Error: "Run-time error '-2147168452 (8004cf3c)':
"Method 'SentOn' of object 'MailItem' failed.

In fact, I've found that very few mailitem properties work for me in the Sent Items folder. E.g., "subject", "Class", "MessageClass" work, but To, SenderName, SentOn, ReceivedTime, CreationTime don't.

Once I get the date/time of the message, I'll be moving it to a location in a different PST based on that date/time. Will I be able to move it ok?
 
D

Dmitry Streblechenko

Is this the code you are using?
ItemTime = MyItems(MyItems.Count).SentOn
It looks like you are casting an integer property (Items.Count) to an object
(MyItems?).

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


Rick Andrews said:
Hi,

I'm trying to archive old emails based on their SentOn, ReceivedTime, or
CreationTime properties. I can get the value for these properties for any
item except the items in the "Sent Items" folder. E.g., when I try to get
the SentOn time, I get an error.
ItemTime = MyItems(MyItems.Count).SentOn

Error: "Run-time error '-2147168452 (8004cf3c)':
"Method 'SentOn' of object 'MailItem' failed.

In fact, I've found that very few mailitem properties work for me in the
Sent Items folder. E.g., "subject", "Class", "MessageClass" work, but To,
SenderName, SentOn, ReceivedTime, CreationTime don't.
Once I get the date/time of the message, I'll be moving it to a location
in a different PST based on that date/time. Will I be able to move it ok?
 
G

Guest

Duh. :) Sorry about that. ItemTime is a Date Variable. MyItems is a collection of Items, i.e.

Dim myItems As Outlook.Item
Dim ItemTime As Dat

I've since found several other times where the SentOn property fails even though the item type is a "MailItem" that aren't in the Sent Items folder. E.g., recall requests return that they are "MailItems"s, but if I query the SentOn date, I get the same error I reported earlier

Ric

----- Dmitry Streblechenko wrote: ----

Is this the code you are using
ItemTime = MyItems(MyItems.Count).SentO
It looks like you are casting an integer property (Items.Count) to an objec
(MyItems?)

Dmitry Streblechenko (MVP
http://www.dimastr.com
OutlookSpy - Outlook, CD
and MAPI Developer Too


Rick Andrews said:
CreationTime properties. I can get the value for these properties for an
item except the items in the "Sent Items" folder. E.g., when I try to ge
the SentOn time, I get an error
"Method 'SentOn' of object 'MailItem' failed
Sent Items folder. E.g., "subject", "Class", "MessageClass" work, but To
SenderName, SentOn, ReceivedTime, CreationTime don'tin a different PST based on that date/time. Will I be able to move it ok
 
D

Dmitry Streblechenko

Can you see PR_CLIENT_SUBMIT_TIME and PR_MESSAGE_DELIVERY_TIME on these
messages using MdbView or OutlookSpy?

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


Rick Andrews said:
Duh. :) Sorry about that. ItemTime is a Date Variable. MyItems is a collection of Items, i.e.,

Dim myItems As Outlook.Items
Dim ItemTime As Date

I've since found several other times where the SentOn property fails even
though the item type is a "MailItem" that aren't in the Sent Items folder.
E.g., recall requests return that they are "MailItems"s, but if I query the
SentOn date, I get the same error I reported earlier.
 

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