Esempio n. 1
0
        public void ForkForRecipients(
            out Message msgNew,
            out RecipsAdd recipsAddNew)
        {
            MailMsg pMsgNew;
            IMailMsgRecipientsAdd pRecipsAddNew;

            pMsg.ForkForRecipients(
                out pMsgNew,
                out pRecipsAddNew);

            msgNew       = new Message(pMsgNew);
            recipsAddNew = new RecipsAdd(this, pRecipsAddNew);
        }
Esempio n. 2
0
 public void WriteList(
     RecipsAdd ra)
 {
     ((IMailMsgRecipients) pMsg).WriteList(
         ra.pRecipsAdd);
 }
Esempio n. 3
0
        public void ForkForRecipients(
            out Message msgNew,
            out RecipsAdd recipsAddNew)
        {
            MailMsg pMsgNew;
            IMailMsgRecipientsAdd pRecipsAddNew;

            pMsg.ForkForRecipients(
                out pMsgNew,
                out pRecipsAddNew);

            msgNew = new Message(pMsgNew);
            recipsAddNew = new RecipsAdd(this, pRecipsAddNew);
        }
Esempio n. 4
0
        private bool ReRoute(Recip Recipient, Message Msg, RecipsAdd NewRecipients)
        {
            ActiveDirectory Directory = new ActiveDirectory();

            // TODO: verbose logging
            // Console.WriteLine("Searching for " + proxyAddress + " in " + Directory.UsersLDAPPath.ToString() + ".");

            string[] SearcherPropertiesToLoad = {
                "cn",
                "mail",
                "proxyAddresses"
            };

            DirectorySearcher Searcher = new DirectorySearcher(
             new DirectoryEntry(Directory.UsersLDAPPath),
             "(&(objectCategory=person)(objectClass=user)(| (proxyAddresses=*smtp:@" + Recipient.SMTPAddressDomain.ToLower() + "*)(proxyAddresses=*smtp:" + Recipient.SMTPAddress + "*)))",
             SearcherPropertiesToLoad);

            SearchResultCollection SearchResults = Searcher.FindAll();

            if (SearchResults.Count == 0)
                return false;

            foreach (SearchResult SearchResult in SearchResults)
            {
                foreach (string ProxyAddressProperty in SearchResult.Properties["proxyAddresses"])
                {
                    string ProxyAddress = ProxyAddressProperty.ToLower();
                    if ("smtp:" + Recipient.SMTPAddress.ToLower() == ProxyAddress)
                    {
                        // there's an address that matches exactly, add him to the re-routing
                        // list because there might be other recipients that don't match and
                        // will require routing
                        NewRecipients.AddSMTPRecipient(Recipient.SMTPAddress, null);
                        return false;
                    }
                }
            }

            foreach (SearchResult SearchResult in SearchResults)
            {
                foreach (string ProxyAddressProperty in SearchResult.Properties["proxyAddresses"])
                {
                    string ProxyAddress = ProxyAddressProperty.ToLower();

                    // this is necessary to avoid matching @foo.com with @foo.com.bar
                    if ("smtp:@" + Recipient.SMTPAddressDomain.ToLower() == ProxyAddress)
                    {
                        string RoutedSMTPAddress = SearchResult.Properties["mail"][0].ToString();

                        EventLog.WriteEntry(
                         Assembly.GetExecutingAssembly().FullName,
                         "Routing message " + Msg.Rfc822MsgId + " from " + Recipient.SMTPAddress + " to " + RoutedSMTPAddress + ".",
                         EventLogEntryType.Information);

                        NewRecipients.AddSMTPRecipient(RoutedSMTPAddress, null);
                        return true;
                    }
                }
            }

            return false;
        }
Esempio n. 5
0
 public void WriteList(
     RecipsAdd ra)
 {
     ((IMailMsgRecipients)pMsg).WriteList(
         ra.pRecipsAdd);
 }