I hope someone can help me. The e-mail service gives me a 404 when it tries to download the template. When I browse to my e-mail template it pop's up ust fine. I've made sure there is only one domain name set, republished the entire site and checked the domain name on the store settings. No luck so far. The domain name I'm using is: mysite.nl (no www prefix!)
The code that fails in the UCommerce.dll (Version=3.6.1.13149) is (UCommerce.Transactions.EmailService):
publicvirtualstringSend(ILocalizationContext localizationContext, EmailProfile profile, string emailTypeName, MailAddress to, System.Collections.Generic.IDictionary<string, string> templateParameters)
{ if (!EmailType.Exists((EmailType x) => x.Name == emailTypeName))
{ thrownewConfigurationErrorsException(string.Format("Could not find an e-mail type named '{0}'. Please make sure that Settings -> E-mails -> Types contains a type called '{0}'.", emailTypeName));
}
EmailContent content = profile.GetContent(emailTypeName, localizationContext.CurrentCultureCode); if (content == null)
{ thrownewConfigurationErrorsException(string.Format("Cannot find template for e-mail type '{0}' and culture '{1}'. Make sure that a template is configured for e-mail type {0} on profile {2}.", emailTypeName, localizationContext.CurrentCultureCode, profile.Name));
}
EmailProfileInformation profileInformation = profile.GetProfileInformation(content.EmailType); string contentId = content.ContentId;
Uri relativeUri = newUri(this.ContentService.GetContentUrl(contentId), UriKind.RelativeOrAbsolute);
Uri uri = newUri(HttpContext.Current.Request.Url, relativeUri);
WebClient webClient = newWebClient(); byte[] bytes = webClient.DownloadData(uri.AbsoluteUri + this.BuildQueryStringParameters(templateParameters)); // CRASHES HERE
System.Text.UTF8Encoding uTF8Encoding = new System.Text.UTF8Encoding();
System.Net.WebExceptionThe remote server returned an error: (404) Not Found.
UCommerce.Pipelines.PipelineException: Exception occoured while processing pipeline 'UCommerce.Pipelines.Checkout.CheckoutPipeline'. See inner exception for details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.WebClient.DownloadDataInternal(Uriaddress, WebRequest&request)
at System.Net.WebClient.DownloadData(Uriaddress)
at UCommerce.Transactions.EmailService.Send(ILocalizationContextlocalizationContext, EmailProfileprofile, StringemailTypeName, MailAddressto, IDictionary`2templateParameters)
at UCommerce.Pipelines.Common.SendEmailTask.Execute(PurchaseOrderpurchaseOrder)
at UCommerce.Pipelines.Pipeline`1.Execute(Tsubject)
--- End of inner exception stack trace ---
at UCommerce.Pipelines.Pipeline`1.Execute(Tsubject)
Some extra information. Since the e-mail templates reside outside the default HOME node, we've set the hostname on the parent folder of the e-mail templates: mysite.nl/email.
The hostname from the original request is used for getting the email content. So please make sure the hostname can be resolved correctly.
A typical issue is that the internal DNS lookup fails for the hostname, then the request gets passed to "outside" the firewall. Then the request is not allowed back inside the firewall.
One way of getting around it is to add the hostname to the hosts file, if you have control over the machine.
Please note that content and email must be on the same hostname.
Hi, we are still looking in to this. I would advise uCommerce to re-think the way this works. I dont see why a webrequest is needed when the e-mail templates are on the same server: You can use IO to read the file on disk (e-mail template) and then replace the placeholders in that template with the appropiate content. For example:
/// <summary>
/// Get html template
/// </summary>
/// <param name="template"></param>
/// <returns></returns>
public static string GetTemplate(Template template, Dictionary<string, string> arguments)
{
var templateContent = String.Empty;
var fileName = StringValueAttribute.GetStringValue(template);
var key = "MySite.Library.Helpers.MailHelper:GetTemplate_" + fileName;
if (CacheHelper.Exists(key)) {
templateContent = CacheHelper.Get<string>(key);
}
else {
var templatePath = HttpContext.Current.Server.MapPath(
ConfigurationManager.AppSettings["Site.Email.TemplatePath"]);
if (System.IO.Directory.Exists(templatePath)) {
if (!templatePath.EndsWith("\\")) {
templatePath += "\\";
}
templatePath += fileName;
// read template contents
if (System.IO.File.Exists(templatePath)) {
try {
templateContent = System.IO.File.ReadAllText(templatePath);
if (!String.IsNullOrEmpty(templateContent)) {
foreach (var argument in arguments) {
templateContent = templateContent.Replace(argument.Key, argument.Value);
}
}
CacheHelper.Add(templateContent, key);
} catch (Exception ex) {
ExceptionHelper.LogException(ex);
}
}
}
}
return templateContent;
}
404: UCommerce.Transactions.EmailService: Send()
Hi,
I hope someone can help me. The e-mail service gives me a 404 when it tries to download the template. When I browse to my e-mail template it pop's up ust fine. I've made sure there is only one domain name set, republished the entire site and checked the domain name on the store settings. No luck so far. The domain name I'm using is: mysite.nl (no www prefix!)
The code that fails in the UCommerce.dll (Version=3.6.1.13149) is (UCommerce.Transactions.EmailService):
Some extra information. Since the e-mail templates reside outside the default HOME node, we've set the hostname on the parent folder of the e-mail templates: mysite.nl/email.
Hi Wouter,
The hostname from the original request is used for getting the email content. So please make sure the hostname can be resolved correctly.
A typical issue is that the internal DNS lookup fails for the hostname, then the request gets passed to "outside" the firewall. Then the request is not allowed back inside the firewall.
One way of getting around it is to add the hostname to the hosts file, if you have control over the machine.
Please note that content and email must be on the same hostname.
Kind regards,
Jesper
Hi, we are still looking in to this. I would advise uCommerce to re-think the way this works. I dont see why a webrequest is needed when the e-mail templates are on the same server: You can use IO to read the file on disk (e-mail template) and then replace the placeholders in that template with the appropiate content. For example:
is working on a reply...