Suppose we want to Approve the Email for the mailbox of the user(s) programmatically.
We’d see the below notification for the user whose mailbox is not yet approved.
Email won’t be processed for this mailbox until the email address of the mailbox is approved by an Office 365 Global Administrator or by an Exchange Administrator. For more information, contact your system administrator.
Below is the sample code –
On running the code, we can see the notification for the email address approval removed or the mailbox approved for the user.
C# Code –
CrmServiceClient svc = new CrmServiceClient(ConnectionString);
var systemUser = new Entity("systemuser", new Guid("C48A539A-F493-EC11-B400-000D3A4F37D3"));
// emailrouteraccessapproval - status of the primary email address
//0 = Empty, 1 = Approved, 2 = Pending Approval, 3 = Rejected
systemUser.Attributes["emailrouteraccessapproval"] = new OptionSetValue(1);
The code should run under the context of the user who has either Global Admin or Exchange Admin role.
We can see few default User Filters already defined that syncs records owned by the current user.
Users can create new filters, edit the existing filters, delete, activate, deactivate and reset the filters.
These filters like personal filters applied to that particular user only.
The same can also be accessed from Personalization Settings
Personal Options > Synchronization tab
Similar to User Filters we can define System Filters that apply to the entire organization or all the users.
As we can see there are no options (no new button) to create new System Filters from the user interface. The only way we can create them is through SDK.
Suppose we don’t want any tasks to be synced.
For this, we can create a filter like “sync only those tasks where created on doesn’t have value” which will always evaluate to false.
On executing the below code
We can see the system filter created successfully.
Hope it helps..
Entity savedQuery = new Entity("savedquery");
savedQuery.Attributes["name"] = "System Filter for Task";
savedQuery.Attributes["description"] = "To restrict sync of tasks";
savedQuery.Attributes["isquickfindquery"] = false;
// saved query is of type outlook fiter
savedQuery.Attributes["querytype"] = SavedQueryQueryType.OutlookFilters;
savedQuery.Attributes["returnedtypecode"] = "task";
// sync only those tasks which have created on as null
// this is to restrict task sync
"<attribute name='activityid'/>" +
"<condition attribute='createdon' operator='null'/>" +
var response= svc.Create(savedQuery);