2015-07-02 80 views
0

我是VBA中的新成員。我想問一下如何觸發已回覆的郵件。從已回覆的電子郵件中自動觸發

情景:我有這個編碼如下這將電子郵件發送至接收方(列B)如果是「是」,在C列

For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants) 
     If cell.Value Like "?*@?*.?*" And _ 
      LCase(Cells(cell.Row, "C").Value) = "yes" Then 

      Set OutMail = OutApp.CreateItem(0) 
      On Error Resume Next 
      With OutMail 
       .To = cell.Value 
       .Subject = "Reminder" 
       .Body = "Dear " & Cells(cell.Row, "A").Value _ 
         & vbNewLine & vbNewLine & _ 
         "Please contact us to discuss bringing " & _ 
         "your account up to date" 
       'You can add files also like this 
       '.Attachments.Add ("C:\test.txt") 
       .Send 'Or use Display 
      End With 

問:我怎樣才能觸發如果收件人已回覆我之前寄給我的電子郵件?我想將觸發器自動化到列E上的excel文件,因爲備註收件人已回覆我的電子郵件。例如,「回覆/無回覆」。

因爲我是VBA的新人,對於任何幫助都非常感謝。 謝謝。

回答

0

假設您使用Microsoft Outlook和Exchange Server。

有跡象表明,有用於答覆/轉發的消息狀態處理3個擴展MAPI屬性:

PR_ICON_INDEX(0x10800003)
PR_LAST_VERB_EXECUTED(0x10810003)
PR_LAST_VERB_EXECUTION_TIME(0x10820040)

此MSDN文章https://msdn.microsoft.com/en-us/library/bb176395(office.12).aspx提供了演示如何使用這些MAPI屬性的代碼:

Sub DemoPropertyAccessorGetProperty() 
    Dim PropName, Header As String 
    Dim oMail As Object 
    Dim oPA As Outlook.PropertyAccessor 
    'Get first item in the inbox 
    Set oMail = _ 
     Application.Session.GetDefaultFolder(olFolderInbox).Items(1) 
    'PR_TRANSPORT_MESSAGE_HEADERS 
    PropName = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
    'Obtain an instance of PropertyAccessor class 
    Set oPA = oMail.PropertyAccessor 
    'Call GetProperty 
    Header = oPA.GetProperty(PropName) 
    Debug.Print (Header) 
End Sub 

您將要取代「PR_TRANSPORT_MESSAGE_HEADERS即0x007D001E在上面的代碼,我猜你會想通過不僅僅是第一個郵件項目更多...