0
votes

I am working on an automation on mails in outlook VBA. I want to use PR_VERB_EXECUTION_TIME property to get the latest status of mail and check whether the mail has already been replied or forwarded and send mail if the mail is unattended. Any help in

Sub Test(Item AS MailItem)
//Item is my incoming mail
Dim Obj As Outlook.MailItem
Dim str As String
Dim propaccessor As Outlook.Propertyaccessor
Set propaccessor = Item.propertyAccessor

str = propaccessor.Getproperty("http://schemas.microsoft.com/mapi/proptag/0x10820040")

'Str value is setting to null due to which error is thrown
'but other properties are working fine
'i want to use this string and compare current time and then reply if it is equal to current time

End Sub

how to use the property is appreciated!.

1
what have you tried so far? Check the help center and How to Ask for tips on improving the quality of your question. Consider adding an minimal reproducible example which illustrates what you've tried so far along with an explanation of your specific problems/errors. - David Zemens
PR_LAST_VERB_EXECUTED will always be 0 and PR_VERB_EXECUTION_TIME will always be null on incoming mail. These properties are for mail where you have replied. - niton
thanks for the info niton. But how can i make this check on incoming mail whether someone replied to it. This case comes when i receive mails with a delay from the server when i open my outlook so i have to avoid replying to a mail which has already been replied - dinesh kumar

1 Answers

2
votes

for that you need to use PropertyAccessor.GetProperty Method

    For Each mailItem In mailitems
     If mailItem.Class <> olMail Then Exit For
     Set propertyAccessor = mailItem.propertyAccessor
     LastVerbExecuted = CheckBlankFields("PR_LAST_VERB_EXECUTED", propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10810003"))
     Select Case LastVerbExecuted
       Case Last_Verb_Reply_All, Last_Verb_Reply_Sender, Last_Verb_Reply_Forward
          Subject = mailItem.Subject
          'This appears to be local time
          RecievedTime = mailItem.ReceivedTime
          'This appears to be GMT
          strRepliedTime = CheckBlankFields("PR_LAST_VERB_EXECUTION_TIME", propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10820040"))
          OriginalAuthor = mailItem.Sender
          'Replier = ...
          If strRepliedTime <> "" Then
            'Convert string strRepliedTime to time format here...using a custom function
          End If
          LogData Subject, OriginalAuthor, Replier, RecievedTime, RepliedTime
       Case Else
         'in case you want to do something here
     End Select
   Next mailItem

Refer http://www.tek-tips.com/viewthread.cfm?qid=1739523

you can do this way

        Const Last_Verb_Reply_All = 103
    Const Last_Verb_Reply_Sender = 102
    Const Last_Verb_Reply_Forward = 104
    For Each mailItem In mailitems
     If mailItem.Class <> olMail Then Exit For
     Set propertyAccessor = mailItem.propertyAccessor
     LastVerbExecuted = CheckBlankFields("PR_LAST_VERB_EXECUTED", propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10810003"))
     Select Case LastVerbExecuted
       Case Last_Verb_Reply_All, Last_Verb_Reply_Sender, Last_Verb_Reply_Forward
            'it means email already responded   
            exit sub
            'i dont think there is need to check time
          'strRepliedTime = CheckBlankFields("PR_LAST_VERB_EXECUTION_TIME", propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10820040"))
       Case Else
         'in case you want to do something here
     End Select
    Next mailItem