Click or drag to resize

Implementing features

CodeTwo Exchange Rules SDK provides libraries for .NET platforms. These libraries can be used to create custom applications integrated with the Exchange Rules Service. Therefore, you can use this SDK to implement the following features of the program into a custom app:

The example below shows the implementation of selected API features in a custom application. A detailed information on each feature provided via the API can be found in the subsequent sections of this documentation.

C#
//Create a new rule
var rule = new Settings.RuleDesc();
rule.ID = Guid.NewGuid().ToString();
rule.Name = "Sample name";

//Activate the rule
rule.Active = true;

//Create a Block message action
rule.Actions.Add(new Settings.Actions.ActionBlockMessage());

//Apply the action if the recipient's SMTP address equals a defined value
var filterRecipietAddress = new ER.Shared.Settings.Filters.FilterUserSmtpAddress();
filterRecipietAddress.Addresses = new string[] { "manager@domain.com" };
filterRecipietAddress.PersonType = ER.Shared.Settings.Filters.EnumPersonType.Recipient;
rule.Conditions.Add(filterRecipietAddress);

//Don't apply the action if the sender is a selected Active Directory user
var filterUserIsAdUser = new ER.Shared.Settings.Filters.FilterUserIsAdUser();
filterUserIsAdUser.PersonType = ER.Shared.Settings.Filters.EnumPersonType.Sender;
filterUserIsAdUser.DistinguishedName =
    new C2Common.AD.CDistinguishedName("CN=Patryk,OU=Users,OU=Developers,DC=company,DC=local");
rule.Exceptions.Add(filterUserIsAdUser);

//Stop processing more rules if the current rule is applied
rule.ProcessingOptions.StopIfApplied = true;

//Create a snapshot for adding the rule
var snapshotCreate = new Settings.ItemsSnapshotT<Settings.RuleDesc>();
snapshotCreate.NewItems = new Settings.RuleDesc[] { rule };
snapshotCreate.AllItemsIds = snapshotCreate.NewItems.Select(r => r.ID).ToArray();

//Upload the snapshot to SettingsStorage
var client = new ER.SDK.SettingsStorageClient("SettingsStorageHttpEndpoint");
client.UploadChanges(null, snapshotCreate);

//Download advanced settings
var settings = client.DownloadAdvancedSettings();

//Enable message splitting
settings.SplitMessages = true;

//Create a new tenant
var tenant = new Settings.Advanced.Tenant();
tenant.Name = "Sample tenant";
tenant.LdapPropertyName = "extensionAttribute15";
tenant.ComparisonType = C2Common.AD.EnumComparsionType.typeEquals;
tenant.PropertyValue = "sample1";
settings.Tenants.Add(tenant);

//Upload the advanced settings back to the server
client.UploadAdvancedSettings(settings);
See next

Rules - learn what operations can be performed on rules and how to implement these operations in a custom app via the provided API.

See also

Types of authentication - advanced settings responsible for adjusting the type of authentication while connecting a custom app to the Settings Storage WCF Service.

Generating API Clients from WSDL - learn how to use the API.

Features not available via API - list of features unavailable in the current version of the API.

A ready-made sample of an ASP.NET web app - a sample source code for a custom app. This code may be implemented in a production environment straight after downloading CodeTwo Exchange Rules SDK.

CodeTwo Exchange Rules API reference - a list of libraries with classes representing the provided API.