Checking if a MailItem is a reply

2020-05-09 09:44发布

问题:

Given a MailItem, how do I tell if it's a reply to another email?

Alice sends an email to Bob. Bob replies to Alice. When Bob replies, I want to BCC the reply to Charlie. I'm using Application_ItemSend on Bob's machine to do this every time he sends an email to Alice, but I only want to BCC to Charlie when Bob is replying to Alice (not starting a new chain). How can I do that, if possible?

回答1:

You can check the length of the MailItem.ConversationIndex property - if it is 44 (hex string, 22 bytes for the PR_CONVERSATION_INDEX property), it is a new message, if it is longer than that, it is a reply/forward. See https://msdn.microsoft.com/en-us/library/office/cc765583.aspx?f=255&MSPPError=-2147217396 for more details.

You can also check the subject prefix for RE FW, etc., but the subject can be modified, plus the values are locale specific.