Muokkaa

Jaa


Configure Exchange folder-level tracking rules

Configure folder-level tracking rules to map a Microsoft Exchange inbox folder to a Dynamics 365 Customer Engagement (on-premises) record so that all the emails in the Exchange folder get automatically tracked against the mapped record in Customer Engagement. Folder-level tracking of emails will work only if:

  • The folder-level tracking feature is enabled for your Customer Engagement instance. You can enable folder-level tracking by using the web client or Microsoft Dynamics 365 for Outlook. More information: Configure folder-level tracking

  • The folder that you are tracking is under the Inbox folder in Exchange. Emails in the folders that are not under the Inbox folder won’t be tracked.

Create and manage folder-level tracking rules

Use the MailboxTrackingFolder Entity to programmatically configure and manage your folder-level tracking rules. To set up a tracking rule, use the following attributes.

Attribute Description
ExchangeFolderId Specify the Exchange folder ID that you want to map. You can use the Exchange Web Services (EWS) to retrieve the ID of a folder under your Inbox folder. For more information, see MSDN: How to: Work with folders by using EWS in Exchange. This is a required attribute.
MailboxId Specify the mailbox ID in Customer Engagement that you want to create the rule for. This is a required attribute.
RegardingObjectId Set the regarding object in Customer Engagement that you want the specified Exchange folder to be mapped to. This is an optional attribute.

The following sample code shows how you can create a folder-level tracking rule.

// Create a folder-level tracking rule  
MailboxTrackingFolder newTrackingFolder = new MailboxTrackingFolder();  

// Set the required attributes  
newTrackingFolder.ExchangeFolderId = "123456"; // Sample value. Retrieve this value using Exchange Web Services (EWS)  
newTrackingFolder.MailboxId = new EntityReference(Mailbox.EntityLogicalName, _mailboxId);  

// Set the optional attributes  
newTrackingFolder.RegardingObjectId = new EntityReference(Account.EntityLogicalName, _accountId);  
newTrackingFolder.RegardingObjectId.Name = _accountName;  
newTrackingFolder.ExchangeFolderName = "Sample Exchange Folder";  

// Execute the request to create the rule   
_folderTrackingId = _serviceProxy.Create(newTrackingFolder);  
Console.WriteLine("Created folder-level tracking rule for '{0}'.\n", _mailboxName);  

You can create a maximum of 25 folder-level tracking rules per mailbox. The folder ID of the Exchange folder can’t be validated at the time of creating the mapping using SDK. However, as soon as you create a mapping rule, and if the folder ID is invalid, it will show up in the UI in Customer Engagement to indicate that the mapping is invalid.

Any manual changes done to the regarding object in the tracked activity records, created in Customer Engagement as a result of the folder-level tracking rule, will be overridden the next time server-side synchronization occurs. For example, if you have set up a mapping between the Adventure Works folder and the Adventure Works account, all the emails in the Adventure WorksExchange folder will be tracked as activities in Customer Engagement with the regarding set to the Adventure Works account record. If you change the regarding of some activities to any other record, it will automatically be overridden the next time server-side synchronization occurs.

Retrieve folder-level tracking rules for a mailbox

You can retrieve all the folder-level tracking rules for a mailbox by using the RetrieveMailboxTrackingFoldersRequest message. Pass the mailbox ID for which you want to retrieve the rules in the RetrieveMailboxTrackingFoldersRequest.MailboxId property, and execute the message.

The following sample code shows how you can retrieve folder-level tracking rules for a mailbox.

// Retrieve the folder mapping rules for a mailbox  
RetrieveMailboxTrackingFoldersRequest req = new RetrieveMailboxTrackingFoldersRequest  
{  
    MailboxId = _mailboxId.ToString()  
};  

RetrieveMailboxTrackingFoldersResponse resp = (RetrieveMailboxTrackingFoldersResponse_serviceProxy.Execute(req);  
Console.WriteLine("Retrieved folder-level tracking rules for {0}:", _mailboxName);  
int n = 1;  
foreach (var folderMapping in resp.MailboxTrackingFolderMappings)  
{  
    Console.WriteLine("\tRule {0}: '{1}' is mapped to '{2}'.",   
        n, folderMapping.ExchangeFolderName, folderMapping.RegardingObjectName);  
    n++;  
}  

See also

RetrieveMailboxTrackingFolders Function
MailboxTrackingFolder Entity
Mailbox Entity
Configure folder-level tracking
Server-side Synchronization Entities