Extracting Original Created and Modified Dates from email

I'm trying to programmatically get the original or initial created and modified dates of email items from NSF. I'm doing this programmitcally using VB .NET. I'm currently using the properties of document LastModified and Created. But at times, these dates reflect when the items were added to the NSF file and not when they were originally created, and this I need to correct.

In the Lotus client, if you choose to view the document properties of an email, you'll see 4 dates show up.
Created -> Initally
Modified -> Initially
Added -> In this file
Modified -> In this file

The first two I really need, well to be honest, the document created date I retrieve is ok, but the one that's hard to get is the initial or original modified date. I'm using the GetItemValue property to retrieve values and I can't figure out or find anything to tell me what to use for this. I have even tried:


But no luck so far, can anyone give me an idea if they know what I should use? Note that currently I get these values by using:


Help me out guys, please!!!!
Who is Participating?
SquigConnect With a Mentor Author Commented:
This is what I settled on and is giving me the initial dates which I see in Lotus:

myDateTimeCreated = ((DateTime)ltEmail.Created).ToUniversalTime().ToString();

Array itms = (Array)ltEmail.Items;
                            for (int i = 0; i < itms.Length; i++)
                                NotesItem item = (NotesItem)itms.GetValue(i);
                                myDateTimeLastModified = ((DateTime)item.LastModified).ToUniversalTime().ToString();
For original mod date, I believe the field you are looking for is PostedDate.  You can access it's value like this.

SquigAuthor Commented:
The posted date isn't giving me the same date I'm seeing in the interface. As an example an email I'm looking at, using just the document properties in Lotus Notes, these are the values I see below:

PostedDate:  11/14/2003 08:10:08 AM
initial Modified Date:  04/20/2004 6:36:27 PM

So they're even differen't in the interface.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

SquigAuthor Commented:
I see there's a field called "$Modified", but not getting anything from it. I'm accessing like this:

check for $Updated field instead.

also, from an old post somewhere.

 post #8164 * Michael De Meirleir on 12/28/2000  
"Instead of using the LastModified property, The Lotus Knowledgebase advises to get the date via Evaluate("@Modified", documentObj)

SO test both methods and see if they give results.

I hope this helps !
also from the help

  1.      This script gets the date that a document was last modified and puts it into modifyDate. For example, LastModified returns 10/31/95 10:42:31 AM.
Dim doc As NotesDocument
Dim modifyDate As Variant
'...set value of doc...
modifyDate = doc.LastModified
  2.      This script sets the value of the PurgeDate item in a document, based on when the document was last modified. If it was modified 14 or more days ago, it sets the PurgeDate to today. If it was modified between seven and thirteen days ago, it sets the PurgeDate to seven days from today.
Dim doc As NotesDocument
Dim days As Integer
'...set value of doc...
days = Cint( Date - doc.LastModified )
If days > 14 Then
  doc.PurgeDate = Date
  If days > 7  Then
    doc.PurgeDate = Date + 7
  End If      
End If  
Call doc.Save( True, True )
SquigAuthor Commented:
I'm getting errors trying to use PurgeDate and @Modified doesn't seem to contain anything.
look at the doc.LastModified

SquigAuthor Commented:
That's what I was using originally, but this doesn't reflect the original last modified date of the item, but the last modified date of the item within the NSF database.
Try building a view and testing some of the SImple functions, like Last Modified, and last Read or Edited. to see if the correct values show up.

SquigAuthor Commented:
Can you give me an example of building a view to test this?
SquigAuthor Commented:
Using the NotesItem property, I'm able to retrieve the original/initial modified dates so far. Still doing some testing, but so far I'm getting the correct data as I'm seeing in Lotus Notes client interface when I view document properties.
Just a quick comment.  There is a distinct difference between properties and items.  Document properties cannot be gathered using "getItemValue" in LotusScript :)

For example, here is an agent that will collect available dates from sent or delivered mail and display them in a message box:

Sub Initialize
      Dim session As New NotesSession
      Dim db As Notesdatabase
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Set db = session.currentdatabase
      Dim coll As NotesDocumentCollection
      Set coll = db.UnprocessedDocuments
      If coll.count < 1 Then
            Msgbox "Sorry, you need to select a document"
            Exit Sub
      End If
      Dim doc As NotesDocument
      Set doc = coll.getFirstDocument
      Dim theMessage As String
      Dim fieldString As String
      Dim fieldArray As Variant
      Dim strMsg As String
      fieldString= "Created,LastModified,LastAccessed,ForwardedDate,OriginalModTime,PostedDate,DeliveredDate,$MIMETrack"
      fieldArray = Split(fieldString,",")
      While Not Doc Is Nothing
            Forall f In fieldArray
                  Select Case f
                  Case "Created"
                        'This is a document property
                        theMessage = theMessage + "    " + f + ":  " + Format(doc.Created, "mm/dd/yyyy hh:mm:ss AM/PM") + Chr(13)      
                  Case "LastModified"
                        'This is a document property
                        theMessage = theMessage + "    " + f + ":  " + Format(doc.LastModified, "mm/dd/yyyy hh:mm:ss AM/PM") + Chr(13)      
                  Case "LastAccessed"
                        'This is a document property
                        theMessage = theMessage + "    " + f + ":  " + Format(doc.LastAccessed, "mm/dd/yyyy hh:mm:ss AM/PM") + Chr(13)      
                  Case "$MIMETrack"
                        'This is a document item
                        theMessage = theMessage + "    " + f + ": " + Format(Strrightback(doc.GetItemValue(f)(0),"at ",5), "mm/dd/yyyy hh:mm:ss AM/PM")
                  Case Else
                        If doc.HasItem(f) Then
                              'This is a document item
                              theMessage = theMessage + "    " + f + ":  " + Format(doc.GetItemValue(f)(0), "mm/dd/yyyy hh:mm:ss AM/PM") + Chr(13)                  
                        End If
                  End Select                  
            End Forall
            If doc.HasItem("DeliveredDate") Then
                  strMsg = "Here are the DELIVERED dates for this document:" + Chr(13)
                  strMsg = "Here are the SENT dates for this document:" + Chr(13)
            End If
            Msgbox strMsg + Chr(13) + theMessage
            Set doc = coll.getNextDocument(doc)
End Sub

Here are the SENT dates for this document:

    Created:  08/19/2007 07:47:11 PM
    LastModified:  08/19/2007 08:09:19 PM
    LastAccessed:  08/19/2007 08:09:19 PM
    OriginalModTime:  08/19/2007 08:09:19 PM
    PostedDate:  08/19/2007 08:09:19 PM

Here are the DELIVERED dates for this document:

    Created:  09/10/2007 07:39:04 AM
    LastModified:  09/10/2007 07:39:04 AM
    LastAccessed:  09/10/2007 07:39:04 AM
    PostedDate:  09/10/2007 01:08:38 AM
    DeliveredDate:  09/10/2007 07:39:04 AM
    $MIMETrack: 09/10/2007 07:39:04 AM

SquigAuthor Commented:
I'll play around with that and see what I get. But using the lastmodified dates from the items, they reflect the initial modified date I see from an email properties. In testing, all of the items are giving me the same last modified date, so I'm assuming that I can use anyone.
That would be true, if the email wasn't modified after it was received.   (which is normally true) The differences are between sent and delivered email, so some of the items are present in one, but not the other.
It is an old known bug in Notes, which they haven't fixed because there are scripts out there that relied on the bug as standard behavior.  Unforntunately they never a) documented this, nor b) gave an alternative.

On (a), the most they;ve done is the KB article SysExpert mentrioned.  On (b), they give a workaround in the KB article.  Indicentally, I'm basically the author of that article :)

Anyway, form VB.Net you would use NotesSession.Evaluate to get the result.  For example:

Dim s As New NotesSession
Dim doc As NotesDocument
Dim result As variant
doc = s.getDatabase("","somedb.nsf").AllDocuments.GetFirstDocument
result = s.Evaluate("@Modified" , doc)

result now contains a single-element array,  The single element is a datetime value, same as any other LotusScrupt datetime.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.