Developer Forum »
NewsletterUtil.GetTemplateHtml error
15 posts

Hey, I have a problem with the GetTemplateHtml function which can't find a template.

In WAF_Custom/Participation.cs there's a SendReceipt function that tries to send a confirmation email, which it does by getting the body from a different template.

The code looks like this:

var settings = Settings.Get(Session);
                string body = "Email template not set";
                string from = !string.IsNullOrEmpty(Session.GetSite().DefaultFromEmail.Trim()) ? WAFContext.Session.GetSite().DefaultFromEmail : Vars.EmailFromAddressFallback;
                if (settings.EmailParticipationReceiptTemplate.IsSet())
                {
                    body = NewsletterUtil.GetTemplateHtml(this.NodeId, settings.EmailParticipationReceiptTemplate.GetId(), settings.BaseUrl);
                }

The error message is: 

"Error during newsletter generation"

"   at WAF.Common.NewsletterUtil.RetrieveTemplateHtml(String url)\r\n   at WAF.Common.NewsletterUtil.GetTemplateHtml(Int32 nodeId, Int32 templateId, String baseUrl, Uri clientBaseUri)\r\n   at WAF.Common.NewsletterUtil.GetTemplateHtml(Int32 nodeId, Int32 templateId, String baseUrl)\r\n   at WAF.Engine.Content.CM.Participation.SendReceipt() in d:\\Team Foundation Server\\FuturebuiltTFS\\NAL\\NAL_Kursmodulen\\1.x\\www\\App_Code\\WAF_Custom\\CM\\Participation.cs:line 218"

 

{"Unable to connect to the remote server"}

 

"   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)\r\n   at System.Net.WebClient.DownloadString(Uri address)\r\n   at System.Net.WebClient.DownloadString(String address)\r\n   at WAF.Common.NewsletterUtil.RetrieveTemplateHtml(String url)"

 

What I think is a bit weird about this is that I'm not able to get the namespace of the template if i try to get it directly. It's located under CM.Templates.kpmg.Email, but if I try to open it in the Participation.cs file, I can't even find CM.Templates.  

Which means it might be a project error or something else entirely, But I hope you have a clue :)

181 posts

Hi!

Are you sure the settings.BaseUrl is correct? The

{"Unable to connect to the remote server"}

message seems to indicate a problem with the url. 

15 posts

Nope, It was 4003 instead of 4002, easy to miss that.

 

Thanks for the fast reply :)

1