Troubleshooting ECM Message Preview


Description

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:

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)

And in ECM 2.x it is:

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()

TROUBLESHOOTING STEPS

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:

  1. Download ecm.requestbody.aspx.
  2. Put it into the /sitecore/admin folder of the Sitecore solution.
  3. Go to the http://<site>/sitecore/admin/ecm.requestbody.aspx URL.
  4. Set up parameters. Here are some parameters explained:
    • Message Body Item ID - the ID of the item, which represents the message body (check the "Body" field in the Message Item).
    • ECM ID - an internal security ID, which is assigned dynamically by ECM - unique for the Sitecore solution, updated on each recycle. This value should not be changed.
  5. Run a test using the "Check" button.

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.