简体   繁体   中英

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

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM