public static void Run()
        {
            // ExStart:CreateNewRuleOntheExchangeServers
            // Set Exchange Server 2010 web service URL, Username, password, domain information
            string mailboxURI = "https://ex2010/ews/exchange.asmx";
            string username = "******";
            string password = "******";
            string domain = "ex2010.local";

            // Connect to the Exchange Server
            NetworkCredential credential = new NetworkCredential(username, password, domain);
            IEWSClient client = EWSClient.GetEWSClient(mailboxURI, credential);

            Console.WriteLine("Connected to Exchange server");

            InboxRule rule = new InboxRule();
            rule.DisplayName = "Message from client ABC";

            // Add conditions
            RulePredicates newRules = new RulePredicates();
            // Set Subject contains string "ABC" and Add the conditions
            newRules.ContainsSubjectStrings.Add("ABC");
            newRules.FromAddresses.Add(new MailAddress("*****@*****.**", true));
            rule.Conditions = newRules;

            // Add Actions and Move the message to a folder
            RuleActions newActions = new RuleActions();
            newActions.MoveToFolder = "120:AAMkADFjMjNjMmNjLWE3NzgtNGIzNC05OGIyLTAwNTgzNjRhN2EzNgAuAAAAAABbwP+Tkhs0TKx1GMf0D/cPAQD2lptUqri0QqRtJVHwOKJDAAACL5KNAAA=AQAAAA==";
            rule.Actions = newActions;
            client.CreateInboxRule(rule);
            // ExEnd:CreateNewRuleOntheExchangeServer
        }        
        public static void Run()
        {
            // ExStart:CreateNewRuleOntheExchangeServer
            // Set Exchange Server web service URL, Username, password, domain information
            string mailboxURI = "https://ex2010/ews/exchange.asmx";
            string username   = "******";
            string password   = "******";
            string domain     = "ex2010.local";

            // Connect to the Exchange Server
            NetworkCredential credential = new NetworkCredential(username, password, domain);
            IEWSClient        client     = EWSClient.GetEWSClient(mailboxURI, credential);

            Console.WriteLine("Connected to Exchange server");

            InboxRule rule = new InboxRule();

            rule.DisplayName = "Message from client ABC";

            // Add conditions
            RulePredicates newRules = new RulePredicates();

            // Set Subject contains string "ABC" and Add the conditions
            newRules.ContainsSubjectStrings.Add("ABC");
            newRules.FromAddresses.Add(new MailAddress("*****@*****.**", true));
            rule.Conditions = newRules;

            // Add Actions and Move the message to a folder
            RuleActions newActions = new RuleActions();

            newActions.MoveToFolder = "120:AAMkADFjMjNjMmNjLWE3NzgtNGIzNC05OGIyLTAwNTgzNjRhN2EzNgAuAAAAAABbwP+Tkhs0TKx1GMf0D/cPAQD2lptUqri0QqRtJVHwOKJDAAACL5KNAAA=AQAAAA==";
            rule.Actions            = newActions;
            client.CreateInboxRule(rule);
            // ExEnd:CreateNewRuleOntheExchangeServer
        }
Esempio n. 3
0
     : super()
 {
     //// New rule has priority as 0 by default
     this.priority = 1;
     //// New rule is enabled by default
     this.isEnabled  = true;
     this.conditions = new RulePredicates();
     this.actions    = new RuleActions();
     this.exceptions = new RulePredicates();
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rule"/> class.
 /// </summary>
 public Rule()
     : base()
 {
     //// New rule has priority as 0 by default
     this.priority = 1;
     //// New rule is enabled by default
     this.isEnabled = true;
     this.conditions = new RulePredicates();
     this.actions = new RuleActions();
     this.exceptions = new RulePredicates();
 }