private void CheckBCC(IMailItem mail) { // If the item already has a BCC, assume it's correct if (!string.IsNullOrEmpty(mail.BCC)) { return; } // Grab the transport headers string headers = (string)mail.GetProperty(OutlookConstants.PR_TRANSPORT_MESSAGE_HEADERS); if (string.IsNullOrEmpty(headers)) { return; } // Check if there's a bcc header Match match = RE_BCC.Match(headers); if (match.Groups.Count < 2) { return; } string bcc = match.Groups[1].Value; if (string.IsNullOrEmpty(bcc)) { return; } // Add the recipient string decoded = bcc.DecodeQuotedPrintable(); try { using (IRecipients recipients = mail.Recipients) { foreach (string entry in decoded.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None)) { using (IRecipient recip = CreateRecipient(recipients, entry)) { recip.Type = MailRecipientType.BCC; } } } } finally { mail.Save(); } }
/// <summary> /// Updates the local mail item from the current state /// </summary> public void UpdateLocal() { // Determine icon and verb int icon = OutlookConstants.PR_ICON_INDEX_NONE; int verb = OutlookConstants.EXCHIVERB_OPEN; switch (Verb) { case Verb.REPLIED: icon = OutlookConstants.PR_ICON_INDEX_REPLIED; verb = OutlookConstants.EXCHIVERB_REPLYTOSENDER; break; case Verb.REPLIED_TO_ALL: icon = OutlookConstants.PR_ICON_INDEX_REPLIED; verb = OutlookConstants.EXCHIVERB_REPLYTOALL; break; case Verb.FORWARDED: icon = OutlookConstants.PR_ICON_INDEX_FORWARDED; verb = OutlookConstants.EXCHIVERB_FORWARD; break; } // Set the properties _item.SetProperties( new string[] { OutlookConstants.PR_ICON_INDEX, OutlookConstants.PR_LAST_VERB_EXECUTED, OutlookConstants.PR_LAST_VERB_EXECUTION_TIME }, new object[] { icon, verb, Date } ); // And save _item.Save(); }