The Message Preview and Message Rendering interfaces of the ECM module may sometimes show an error as follows:
The common symptom of these issues is NonCriticalException listed in Sitecore log with the .DownloadString method referenced in the stack trace. For example, in ECM 1.3.x it looks like:
And in ECM 2.x it is:ERROR EmailCampaign: The remote server returned an error: (500) Internal Server Error.
Exception: Sitecore.Modules.EmailCampaign.Exceptions.NonCriticalException
Message: The remote server returned an error: (500) Internal Server Error.
Source: Sitecore.EmailCampaign
at Sitecore.Modules.EmailCampaign.Core.WebContent.DownloadString(String url, Boolean useIisCredentials)
at Sitecore.Modules.EmailCampaign.WebPageMail.GetMessageBody()
at Sitecore.Modules.EmailCampaign.Core.MessagePreviewHelper.GetMessageInfo(MessageItem message)
ERROR EmailCampaign: The remote server returned an error: (403) Forbidden.
Exception: Sitecore.Modules.EmailCampaign.Exceptions.NonCriticalException
Message: The remote server returned an error: (403) Forbidden.
Source: Sitecore.EmailCampaign
at Sitecore.Modules.EmailCampaign.Core.WebContent.DownloadString(String url, Boolean useIisCredentials)
at Sitecore.Modules.EmailCampaign.Messages.WebPageMail.GetMessageBody()
at Sitecore.Modules.EmailCampaign.Core.MessageInfo.FillCeInfo()
To troubleshoot and fix this issue, let us review how ECM actually executes the message content rendering.
To render the message content, ECM performs a separate web request (via .NET API, i.e. HttpWebRequest) to the Sitecore solution. This trick allows it to incorporate all the features of the Sitecore rendering engine such as personalization, etc. The request is performed to a URL like:
http://<renderer-URL>/?sc_itemid=<message-item-id>&sc_lang=en&sc_device=<device>&sc_mode=preview&sc_duration=temporary&ec_database=master&ec_recipient=<user-name>&ec_id=<ec_id>
When such a request fails to return the message content, the above-mentioned error is shown to the Sitecore ECM user. Therefore, to resolve the message preview issue, we need to ensure that this specific request will not fail with an exception.
To investigate the actual parameters passed to the message content request URL and the actual response returned, perform the following steps:
In the "Output" section of the page, the response contents will be rendered as is, without any specific ECM logic involved.
Additionally, the "Final URL" section will show the actual URL used to perform the request for the message content.