Skip to content

Instantly share code, notes, and snippets.

@takeruko
Last active June 29, 2021 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeruko/bb38fc932ff0f64dff6c4df0e34403a8 to your computer and use it in GitHub Desktop.
Save takeruko/bb38fc932ff0f64dff6c4df0e34403a8 to your computer and use it in GitHub Desktop.
Outlook VBAでメールにリプライした日時を取得する
Dim m As Outlook.MailItem
Set m = GetMailItem(...) ' リプライした日時を取得したいMailItemを取得するなにか
' MailItemのPropertyAccessorを使ってリプライした日時を取得する
Dim pa As Outlook.PropertyAccessor
Set pa = m.PropertyAccessor
' MailItemの返信済ステータスを取得
' 102: 返信, 103: 全員に返信, 104: 転送
Dim replyStatus As Integer
replyStatus = pa.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10810003")
Select Case replyStatus
Case 102, 103, 104 ' リプライ済の場合だけ、リプライ日時が取得できる
Dim repliedAtUTC As Date, repliedAtJST As Date
repliedAtUTC = pa.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10820040")
repliedAtJST = DateAdd("h", 9, repliedAtUTC) ' リプライ日時はUTCで取れるみたいなので、日本時間に直す(+9時間)
Debug.Print "Replied At:" & repliedAtJST
End Select
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment