【问题标题】:getting the outlook mail's latest status(replied or forwarded)获取 Outlook 邮件的最新状态(已回复或已转发)
【发布时间】:2017-06-15 01:33:16
【问题描述】:

我正在对 Outlook VBA 中的邮件进行自动化处理。我想使用 PR_VERB_EXECUTION_TIME 属性来获取邮件的最新状态,并检查邮件是否已经被回复或转发,如果邮件无人看管,则发送邮件。任何帮助

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

感谢您如何使用该属性!

【问题讨论】:

  • 到目前为止您尝试过什么?查看help centerHow to Ask 以获取有关提高问题质量的提示。考虑添加一个minimal reproducible example,它说明了您迄今为止所做的尝试以及对您的具体问题/错误的解释。
  • PR_LAST_VERB_EXECUTED 将始终为 0,PR_VERB_EXECUTION_TIME 在传入邮件中始终为空。这些属性适用于您已回复的邮件。
  • 感谢您提供的信息。但是我怎样才能检查收到的邮件是否有人回复它。当我打开 Outlook 时收到来自服务器的延迟邮件时会出现这种情况,因此我必须避免回复已回复的邮件

标签: vba outlook


【解决方案1】:

为此,您需要使用PropertyAccessor.GetProperty 方法

    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

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

你可以这样做

        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

【讨论】:

  • 感谢 Maddy,但我的确切情况就像我有一个脚本,它现在一旦到达我的收件箱就会回复邮件,因为它是一个客户端脚本,如果我关闭我的 Outlook,它就不会运行。因此,当我在几个小时后再次打开时,如果有任何邮件并且有人已经回复了这些邮件,我的脚本没有检查它,它正在再次回复。所以,我想在收到的邮件中应用 lastexecutedtime 逻辑,无论它何时到达我的邮箱。
  • @dinesh ..你能用示例代码更新你的问题吗?所以我可以进一步分析
  • @dinesh..一个解决方案可以是您可以在关闭 Outlook 之前禁用脚本,并且每当您启动 Outlook 时首先阅读所有电子邮件,然后启用脚本
  • 是的,现在我在关闭 Outlook 之前手动禁用它。但是,在最坏的情况下,它会产生问题,因此考虑编写此逻辑。我会尽快分享代码
  • 我无法看到您的代码。请在您的问题中更新它
猜你喜欢
  • 2013-02-25
  • 2017-07-06
  • 1970-01-01
  • 1970-01-01
  • 2022-06-29
  • 2020-02-24
  • 1970-01-01
  • 2023-03-23
  • 2018-06-07
相关资源
最近更新 更多