コード例 #1
0
        /// <summary>
        /// Responding event handler. Checks if a send-as address must be specified.
        /// </summary>
        /// <param name="mail"></param>
        /// <param name="response"></param>
        private void MailEvents_Respond(IMailItem mail, IMailItem response)
        {
            Logger.Instance.Trace(this, "Responding to mail, checking");
            using (IStore store = mail.GetStore())
            {
                ZPushAccount zpush = Watcher.Accounts.GetAccount(store);
                Logger.Instance.Trace(this, "Checking ZPush: {0}", zpush);
                if (zpush == null)
                {
                    return;
                }

                // Check if the containing folder is a shared folder
                using (IFolder parent = mail.Parent)
                    using (IRecipient recip = FindSendAsSender(zpush, parent))
                    {
                        if (recip == null || !recip.IsResolved)
                        {
                            return;
                        }

                        // Set the sender
                        Logger.Instance.Trace(this, "Sending as: {0}", recip.Address);
                        using (IAddressEntry address = recip.GetAddressEntry())
                        {
                            response.SetSender(address);
                        }
                    }
            }
        }
コード例 #2
0
 private void MailEvents_Respond(IMailItem mail, IMailItem response)
 {
     Logger.Instance.Trace(this, "Responding to mail, checking");
     using (IStore store = mail.GetStore())
     {
         ZPushAccount zpush = Watcher.Accounts.GetAccount(store);
         Logger.Instance.Trace(this, "Checking ZPush: {0}", zpush);
         if (zpush != null)
         {
             // Check if the containing folder is a shared folder
             using (IFolder parent = mail.Parent)
             {
                 Logger.Instance.Trace(this, "Checking, Parent folder: {0}", parent.Name);
                 SharedFolder shared = _sharedFolders.GetSharedFolder(parent);
                 if (shared != null)
                 {
                     Logger.Instance.Trace(this, "Checking, Shared folder: {0}, flags={1}", shared, shared?.Flags);
                 }
                 else
                 {
                     Logger.Instance.Trace(this, "Not a shared folder");
                 }
                 if (shared != null && shared.FlagSendAsOwner)
                 {
                     Logger.Instance.Trace(this, "Checking, Shared folder owner: {0}", shared.Store.UserName);
                     // It's a shared folder, use the owner as the sender if possible
                     using (IRecipient recip = FindSendAsSender(zpush, shared.Store))
                     {
                         Logger.Instance.Trace(this, "Checking, Shared folder owner recipient: {0}", recip.Name);
                         if (recip != null && recip.IsResolved)
                         {
                             Logger.Instance.Trace(this, "Sending as: {0}", recip.Address);
                             using (IAddressEntry address = recip.GetAddressEntry())
                             {
                                 response.SetSender(address);
                             }
                         }
                         else
                         {
                             Logger.Instance.Error(this, "Unable to resolve sender: {0}", shared.Store.UserName);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
 private void MailEvents_ItemSend(IMailItem item, ref bool cancel)
 {
     using (IStore store = item.GetStore())
     {
         ZPushAccount zpush = Watcher.Accounts.GetAccount(store);
         if (zpush != null)
         {
             string address = item.SenderEmailAddress;
             if (address != null && address != zpush.Account.SmtpAddress)
             {
                 Logger.Instance.Trace(this, "SendAs: {0}: {1}", address, item.SenderName);
                 item.SetProperty(Constants.ZPUSH_SEND_AS, address);
                 if (item.SenderName != null)
                 {
                     item.SetProperty(Constants.ZPUSH_SEND_AS_NAME, item.SenderName);
                 }
             }
         }
     }
 }