Error when generating item URL during sending EXM messages


Description

If the Email Experience Manager (EXM) Manager Root item is located outside the site root items defined in the <sites> section of the Sitecore.config file, the following message might be found in the logs when sending EXM messages:

ERROR [UpdateListSubscriptionHandler] Failed to process list operation for 'xDB.Tracker PII removed'
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: targetSite
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
   at Sitecore.Links.UrlBuilders.BaseUrlBuilder`1.ResolveServer(SiteInfo targetSite)
   at Sitecore.Links.UrlBuilders.ItemUrlBuilder.AddServer(UrlBuildModel model, ItemUrlBuilderOptions options)
   at Sitecore.Links.UrlBuilders.BaseUrlBuilder`1.BuildUrl(Item item, TOptions options)
   at Sitecore.Modules.EmailCampaign.Core.HostnameMapping.HostnameMappingService.GetServerUrl(Item item)
   at Sitecore.Modules.EmailCampaign.Core.Pipelines.GenerateLink.SetServerUrl.Process(GenerateLinkPipelineArgs args)
   ...

Solution

To resolve the issue, add the <site> definition for the EXM manager root by creating a configuration patch file in the \App_Config\Include\zzz folder. The <site> definition must be configured as follows:

For example:

<site name="example" inherits="website" rootPath="/sitecore/content" startItem="/Email" targetHostName="<site host name>" />

Note: If you have several manager roots, you must add the <site> definition for each of them specifically.