如何知道是否收到或發送了電子郵件? (How to know if an e-mail was received or sent?)


問題描述

如何知道是否收到或發送了電子郵件? (How to know if an e‑mail was received or sent?)

我製作了一個 VBA 腳本來將選定的電子郵件保存到不同的文件夾中。

有沒有一種方法可以在沒有用戶輸入的情況下知道是否收到或發送了電子郵件?


參考解法

方法 1:

You can check out the Sender‑related properties of the email item. The MailItem.Sender property which returns or sets an AddressEntry object that corresponds to the user of the account from which the MailItem is sent. Checking that property and comparing to the Accounts configured in Outlook you may conclude where the message comes from. The Accounts collection object contains a set of Account objects representing the accounts available for the current profile. The purpose of the Accounts collection object and the Account object is to allow the enumeration of Account objects in a given profile, the identification of the type of an Account, and the use of a specific Account object to send mail.

方法 2:

The only more or less reliable way is to check if MailItem.ReceivedByXYZ properties (such as ReceivedByEntryID) are set. They seem to be only present on the received messages. But I have seen cases where it was present on the sent messages.

You can check first if the parent folder is Inbox or Sent Items by comparing the current folder's entry id with the entry id of a folder received from Store.GetDefaultFolder using Namespace.CompareEntryIDs. If that fails, check on a ReceivedByXYZ property.

(by z0rdEugene AstafievDmitry Streblechenko)

參考文件

  1. How to know if an e‑mail was received or sent? (CC BY‑SA 2.5/3.0/4.0)

#outlook #vba






相關問題

Outlook 2007/2010 中的 Vspace (Vspace in Outlook 2007/2010)

Outlook 2010 自動完成流(緩存的聯繫人) (Outlook 2010 autocomplete stream ( cached contacts))

如何格式化電子郵件中的字符串以便 Outlook 打印換行符? (How do I format a String in an email so Outlook will print the line breaks?)

通過 Office 加載項將內容添加到 Outlook 電子郵件正文 (Adding content to an Outlook email body via an Office Add-In)

Outlook Addin 中的 Recipient.Name 和 ExchangeUser.Name 有什麼區別? (What is the Difference Between Recipient.Name and ExchangeUser.Name in Outlook Addin?)

運行時錯誤,用於電子郵件自動化的 VBA EXCEL (Runtime Error, VBA EXCEL for email automation)

將 Crystal Reports 轉換為 HTML 並作為正文發送到我的郵件中 (Crystal Reports into HTML and sending in my mail as body)

通過 VBA 將格式化的電子郵件正文複製到新的 Word 文檔中並保留文本格式 (Copy formatted Email body into new Word document via VBA and keep the text formatting)

Outlook 在啟動時忽略加載項的 HKEY_LOCAL_MACHINE 條目 (Outlook ignoring HKEY_LOCAL_MACHINE entry for add-in on startup)

如何知道是否收到或發送了電子郵件? (How to know if an e-mail was received or sent?)

如何從 Excel 表格創建電子郵件? (How to create emails from Excel table?)

如何在 Outlook 正文中左對齊從 Excel 範圍創建的 HTML 表格? (How to Left-Align HTML Table, created from an Excel Range, in an Outlook Body?)







留言討論