• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1007
  • Last Modified:

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:

ltEmail.GetItemValue("Modified")(0)
ltEmail.GetItemValue("$Modified")(0)

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:

ltEmail.LastModified
ltEmail.Created

Help me out guys, please!!!!
0
Squig
Asked:
Squig
  • 8
  • 4
  • 2
  • +2
1 Solution
 
Bill-HansonCommented:
For original mod date, I believe the field you are looking for is PostedDate.  You can access it's value like this.

ltEmail.GetItemValue("PostedDate")(0)
0
 
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.
0
 
SquigAuthor Commented:
I see there's a field called "$Modified", but not getting anything from it. I'm accessing like this:

ltEmail.GetItemValue("$Modified")(0)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SysExpertCommented:
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 !
0
 
SysExpertCommented:
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
Else
  If days > 7  Then
    doc.PurgeDate = Date + 7
  End If      
End If  
Call doc.Save( True, True )
 
0
 
SquigAuthor Commented:
I'm getting errors trying to use PurgeDate and @Modified doesn't seem to contain anything.
0
 
SysExpertCommented:
look at the doc.LastModified

0
 
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.
0
 
SysExpertCommented:
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.

0
 
SquigAuthor Commented:
Can you give me an example of building a view to test this?
0
 
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.
0
 
marilyngCommented:
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)
            Else
                  strMsg = "Here are the SENT dates for this document:" + Chr(13)
            End If
            
            Msgbox strMsg + Chr(13) + theMessage
            
            Set doc = coll.getNextDocument(doc)
            
      Wend
      
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
    $MIMETrack:

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

0
 
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.
0
 
marilyngCommented:
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.
0
 
qwaleteeCommented:
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
s.Initialize
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.
0
 
SquigAuthor 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();
                                break;
                            }
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now