Home > Enterprise >  Why is the creation time property of my Outlook items returning an arbitrary date?
Why is the creation time property of my Outlook items returning an arbitrary date?

Time:05-26

when I run the below module, I get a message box displaying "1/1/4051".

Sub CreateNoteItem()
 
    Dim olApp As Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olNoteItm As Outlook.NoteItem

    Set olApp = Outlook.Application
    Set olNS = olApp.GetNamespace("MAPI")
    
    Set olNoteItm = olApp.CreateItem(olNoteItem)
    
    MsgBox olNoteItm.CreationTime
 
 End Sub

I was expecting a date value such as 44701, etc., or a string similar to when I display "Now" (m/dd/yyyy hh:mm:ss).

This happens not just for note items, but also mail items. My end goal is to use this creation time to then process any items with later creation times.

Thanks!

CodePudding user response:

Call the Save method before getting any date-specific properties.

Sub CreateNoteItem()
 
    Dim olApp As Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olNoteItm As Outlook.NoteItem

    Set olApp = Outlook.Application
    Set olNS = olApp.GetNamespace("MAPI")
    
    Set olNoteItm = olApp.CreateItem(olNoteItem)
    
    olNoteItm.Save
    
    MsgBox olNoteItm.CreationTime
 
 End Sub
  • Related