Developer forum

Forum » Development » CartV2 SendMails

CartV2 SendMails


Reply

My CartV2 can’t send confirmation email. In the log file I reactive the following stack trace:
 

Logging 'Stack Trace':
   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at Dynamicweb.LogToFile.Log(String message, String folder, LogType newLogFile, Boolean useExtendedPropertyLogging, LogElements logElements)
   at Dynamicweb.Ecom7.Cart.Frontend.LogError(Order order, String message, Object[] params)
   at Dynamicweb.Ecom7.Cart.Frontend.CheckoutDone(Order order)
   at Dynamicweb.Ecom7.Cart.CheckoutHandler.CheckoutDone(Order order)
   at Dynamicweb.Ecom7.Cart.DefaultCheckoutHandler.StartCheckout(Order order)
   at Dynamicweb.Ecom7.Cart.Frontend.RenderCheckoutStep(Order order)
   at Dynamicweb.Ecom7.Cart.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.getModule(DataRow& ParagraphRow)
   at Dynamicweb.Frontend.Content.WriteParagraph(ParagraphTemplateJoinClass PTRecord)
   at Dynamicweb.Frontend.Content.CreateContent(ParagraphTemplateJoinClass PTRecord)
   at Dynamicweb.Frontend.Content.CreateParagraph(StringBuilder strContent, ParagraphTemplateJoinClass PTRecord, Int32& TemplateParagraphsWriten, Int32& TemplateParagraphsNotWriten, Int32& TemplateParagraphsColumn, String& SpaceBeforeParagraph, Template& paragraphSetupTemplate, Properties& ModuleSettings)
   at Dynamicweb.Frontend.Content.CreateContentEXE()
   at Dynamicweb.Frontend.Content.CreateContent(Int32 PageID)
   at Dynamicweb.Frontend.Content.getContent(Int32 PageID)
   at Dynamicweb.Frontend.PageView.SetPageTemplateValues()
   at Dynamicweb.Frontend.PageView.Output()
   at Dynamicweb.Frontend.PageviewControl.ParseControls()
   at CITCustomModules.Default.Page_Load(Object sender, EventArgs e)
   at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\7319c309\59d1e155\App_Web_yu6kwqs8.0.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
   at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
   at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
   at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
   at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)


But when debugging through the dynamicweb.dll I get an exception with the following stacktrace:

  at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrderLineTemplateExtenders(Order Order, OrderLine OrderLine, Template Template, TemplateExtenderRenderingState RenderingState)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrderLine(OrderLine OrderLine, Template Template)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrderLines(OrderLineCollection OrderLines, Template ParentTemplate, String LoopName)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrderDetails(Template template, Order order, Boolean extendedProperties)
   at Dynamicweb.Ecom7.Cart.Frontend.SendMails(Order order, ModuleSettings settings)
   at Dynamicweb.Ecom7.Cart.Frontend.CheckoutDone(Order order)

The line generating the exception I marked with red


while (enumerator2.MoveNext())
{
System.Type addInType = (System.Type) enumerator2.get_Current();
OrderLineTemplateExtender extender = (OrderLineTemplateExtender) AddInManager.CreateAddInInstance(addInType);
extender.Order = Order;
extender.OrderLine = OrderLine;
extender.User = this.PageView.User;
extender.ExtendTemplate(Template, RenderingState);
}

This.PageView  is null, because the PageView isn’t passed to the Renderer class from the SendMails method.


enumerator3 = source.Distinct<MailAddress>().GetEnumerator();
  while (enumerator3.MoveNext())
  {
 MailAddress address = enumerator3.Current;
 MailMessage mailObj = new MailMessage();
 mailObj.set_IsBodyHtml(true);
 mailObj.set_Subject(current.Subject);
 mailObj.set_From(new MailAddress(current.SenderMail, current.SenderName));
 mailObj.To.Add(address);
 mailObj.set_BodyEncoding(System.Text.Encoding.GetEncoding(current.EncodingCodePage));
 Dynamicweb.Templatev2.Template template = new Dynamicweb.Templatev2.Template(current.Template);
 template.SetTag("Ecom:Order.ReceiptURL", CartUrl(order));
 new Dynamicweb.eCommerce.Frontend.Renderer().RenderOrderDetails(template, order, true);
 mailObj.set_Body(template.Output());
 EmailHandler.Send(mailObj);
  }


Is this a bug or am I doing something wrong?


Replies

 
Nicolai Høeg Pedersen
Reply
It looks like an installation issue...

Can you provide a link to the solution?

If it is not hosted here, you have to check that the local pickup directory (smtp service) is correctly setup and/or that the SMTP server in /Files/Globalsettings.aspx is valid for the server you are hosting on.
 
Reply
 
I ran into the exact same problem when trying to generate mails on order state change.
 
I guess it is only possible to render an order with extenders when you are triggering it in frontend (having a valid pageview and user).
 
// this works (without extended order details)
new Dynamicweb.eCommerce.Frontend.Renderer().RenderOrderDetails(template, order, false);
 
// this fails (with extended order details)
new Dynamicweb.eCommerce.Frontend.Renderer().RenderOrderDetails(template, order, true);
 
DW 19.1.2.1
 
/Morten
 
Reply
there is currently no external access to the solution.

The smtp server setup is valid, it's possible to send user credentials from Admin usermanagement.

I thing Morten is right, but this must be a bug?



 
Nicolai Høeg Pedersen
Reply
Well no - the cart checkout is handled by some settings which is found on a page - without this page there are no settings and it cannot do what it should.

You can always create a pageview with pageview.getpageviewbyid()
 
Reply
Sorry but i don't understand this.

The CartV2 module is sending the confirmation mails and the CartV2 modult is placed on at page...

I have a ordertemplate and orderlinetemplate extender but i don't overside any of the sendmails function?

 
Nicolai Høeg Pedersen
Reply
Ok - thought you had made some kind of custom thing.

Try posting all of your add-in. It might be a bug, but I'm not sure i've understood your context correctly - so please post your code.

Does it work without your code?
 
Reply
I can't post all my custom code, but if i remove my OrderlineTemplateExtender i works!

But that is not a solution...
 
Nicolai Høeg Pedersen
Reply
ok - can you post your orderline template extender? Just zip it and add it or send it on a mail...
 
Reply
My Orderlinetempleteextender is attached, but it's not the extender that generates the exception.

 
Nicolai Høeg Pedersen
Reply
I know - but its the invoke of it that does - we need to find out why. I'll have a look.
 
Reply
Any news?
 
Nicolai Høeg Pedersen
Reply
We have a hotfix coming up with this one...

We just made the fix - will make a build later this afternoon.
 
Reply

Thanks for your reply.

When will it be ready for download?

 
Nicolai Høeg Pedersen

 

You must be logged in to post in the forum