我已将 Outlook 电子邮件数据导出到 Excel。
现在,我遇到的另一个问题是 PR_LAST_VERB_EXECUTION_TIME 不显示为相同的日期格式。
日期可以是ddmmyyyy hh:mm:ss AM/PM 或 mmddyyyy hh:mm格式(请参考 img)。
我还确保所有单元格格式都是通用的。
是否可以标准化日期格式或可能有任何其他原因导致这种情况?
我的代码如下:
For Each itm In Items
'Check item type
If TypeName(itm) = "MailItem" Then
intColumnCounter = 1
Set msg = itm
intRowCounter = intRowCounter + 1
Set rng = wks.Cells(intRowCounter, intColumnCounter)
rng.Value = GetLastVerb(msg)
End If
Next
Function GetLastVerb(olkMsg As Outlook.MailItem) As String
Dim intVerb As Integer
intVerb = GetProperty(olkMsg, "http://schemas.microsoft.com/mapi/proptag/0x10810003")
Select Case intVerb
Case 102
Debug.Print ("Reply to Sender")
GetLastVerb = GetLastVerbTime(olkMsg)
Case 103
Debug.Print ("Reply to All")
GetLastVerb = GetLastVerbTime(olkMsg)
Case 104
Debug.Print ("Forward")
GetLastVerb = olkMsg.ReceivedTime
Case 108
Debug.Print ("Reply to Forward")
GetLastVerb = GetLastVerbTime(olkMsg)
Case Else
Debug.Print ("Unknown")
GetLastVerb = olkMsg.ReceivedTime
End Select
End Function
Public Function GetProperty(olkItm As Object, strPropName As String) As Date
Dim olkPA As Outlook.PropertyAccessor
Set olkPA = olkItm.PropertyAccessor
GetProperty = olkPA.GetProperty(strPropName)
Set olkPA = Nothing
End Function
Function GetLastVerbTime(olkItm As Object) As Variant
GetLastVerbTime = GetDateProperty(olkItm, "http://schemas.microsoft.com/mapi/proptag/0x10820040")
End Function
Public Function GetDateProperty(olkItm As Object, strPropName As String) As Date
Dim olkPA As Outlook.PropertyAccessor
Set olkPA = olkItm.PropertyAccessor
GetDateProperty = olkPA.UTCToLocalTime(olkPA.GetProperty(strPropName))
Set olkPA = Nothing
End Function