Problem with transport??? Received date not registered on saved message.

J

Jim Schacht

Greetings,

I'm having a heckofa time with the code below. After executing this code in
Outlook XP, I expect the copied item (itmNew) to have a received time/date
stamp because the Save method was executed. When I debug the code I see
that the "Saved" flag returns true, but the "ReceivedTime" value returns
1/1/4501. When I view the item in the explorer window I see that the
received date is "none". From my reading I see that this date is generated
by the transport provider.

I'm not sure if this is pertinent, but the location the item is saved to is
not in the default information store for the profile.

This is about to drive me batty so any help will be greatly appreciated!

<snip>
'If a folder is picked, the following attributes are given to the outbound
message, a copy is made,
'and it is sent.
If fldDestination > "" Then
With itmCurrent
.SentOnBehalfOfName = "Omitted"
.DeleteAfterSubmit = True
strSubject = .Subject
Set itmNew = .Copy
.Send
End With
End If

'The copy is moved to the folder chosen in the folder picker dialog
Dim propEntryID, propStoreID
With itmNew
.Save
propEntryID = .EntryID
.Close (olSave)
End With
<end snip>

Thank you!
Jim
 
J

Jim Schacht

I'm sorry - I made an error on the code snippet I posted. I had removed the
Move method in my example and was experimenting with the Close method. In
my real code I call "Move fldDestination" in place of the line below that
reads ".Close (olSave)"

Jim
 
S

Sue Mosher [MVP-Outlook]

This is normal behavior. An unsent item will have a ReceivedTime of
#1/1/4501# which is what Outlook stores when it shows "None" in the UI.
 
J

Jim Schacht

Thanks Sue.

Is there any way I can work around this? It is important for me to have a
received time-stamp on these copied items: it is a crucial piece of a
workflow design. I've noticed that when I open the item and then save it
without sending, the ReceivedTime is changed to Now. What is different
about saving a message that way than calling the Save method? Any
suggestions will be greatly appreciated.

Jim
 
S

Sue Mosher [MVP-Outlook]

A better design might be to use DeleteAfterSubmit = False and monitor the
Sent Items folder for the actual sent items and move copies of those. They
will have acurate date/time stamps that reflect when the item was submitted
to the workflow (assuming you're sending these items?)

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

Jim Schacht

Excellent suggestion. I am sending the original message. I think I went
down this road many months ago when I first started looking at the project
and could not figure out how to monitor the sent items. Do you know of any
examples I could use to get me started?

Best regards,
Jim
 
S

Sue Mosher [MVP-Outlook]

The method is the same for any folder -- use the MAPIFolder.Items.ItemAdd
event. For an example using the Inbox, see
http://www.outlookcode.com/d/code/quarexe.htm

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

Jim Schacht

Sue:
As usual, you have saved the day!

I really appreciate how you help. You give enough information to get me
going in the right direction, and let me find the way from there. I learn a
lot that way. Thanks a million!

I've got my code worked out and it's working great with one small problem
(unrelated to the problem you fixed). I'm thinking that I probably just
have my logic wrong, but here's the code (the problem and question will
follow):
<snip>
Private Sub olSentMailItems_ItemAdd(ByVal Item As Object)
On Error Resume Next
Set objNS = Application.GetNamespace("MAPI")
Set objSentMail = objNS.GetDefaultFolder(olFolderSentMail)
'fldDestination is a global variable for the sentitems folder the code only
executes if there is a value for this variable
'if there is no value for fldDestination the message is ignored.
If fldDestination Then
If InStr(1, Item.Subject, strSubject, vbTextCompare) Then
Item.ShowCategoriesDialog
Item.Move fldDestination
End If
End If
Set fldDestination = Nothing
strSubject = ""
End Sub
<end snip>

The problem is that the Category dialog comes up regardless of the whether
the If statement is true or not! What am I doing wrong?

Kind regards,
Jim
 
J

Jim Schacht

One of these days I will learn to proofread BEFORE I send! I made an error
in my comments and I want to clarify so as not to confuse.

CORRECTION: 'fldDestination is a global variable for the FOLDER CHOSEN
BY THE FOLDER PICKER, the code only...

Thanks,
Jim
 
S

Sue Mosher [MVP-Outlook]

The problem is that the Category dialog comes up regardless of the whether
the If statement is true or not! What am I doing wrong?

fldDestination is a MAPIFolder object, not a Boolean variable. Try this:

If Not fldDestination Is Nothing Then
If InStr(1, Item.Subject, strSubject, vbTextCompare) > 0 Then

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Easy! Take the knowledge you've gained and share it with other people here
by answering their questions.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Top