Developer forum

Forum » Development » Order receipt mail not send after checkout is complete

Order receipt mail not send after checkout is complete

Dmitrij Jazel
Reply
Hi guys,
I have a custom module here, that is a subscribed to:
[Subscribe(Dynamicweb.Notifications.eCommerce.Cart.OrderIsPassedToCheckoutHandler)]
As I would imagine this is just an event, and if I am not changing nothing in standard flow (not triggering other events or making some changes in standard flow), it should continue, and eventually send a mail with order out to the emails stated in the cart module with the templates.

But it seams that the mail is not send. And I am wondering why.
Or maybe is it possible for me to deliberately trigger to send email to those stated in the cart module with the template chosen in the cart module settings?

Kind regards,
Dmitrij

Replies

 
Vladimir
Reply
Hi Dmitrij!
The presence of the OrderIsPassedToCheckoutHandler does should not affect to the sending of mails.
So if mails are sent without it, and with it not, what is a something wrong happens in the handler.
Can you show me handler's code ?

Best regards,
Vladimir

 
Dmitrij Jazel
Reply
Hello Vladimir,

Can I send it to your email please, it will be a bit too big here (I think).
Can you contact me via jazel.d@gmail.com ?
Generally I am not doing anything special, just gathering order information from the order object in the event... And making some calls to the DataBase eventually to save those in my own tables...
I think it should just continue and emails should have been eventually send...

Kind regards,
Dmitrij
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Can I send it to your email please, it will be a bit too big here (I think).

You can upload the code as a .txt file which makes it a bit easier to share and see for others.

Cheers,

Imar
 
Dmitrij Jazel
Reply
Nah... how could I forget, usually use it for image attachments, I just add the class right here :-)
Hope this can bring some more lights on what is going on... 

The exact problem is that after checkout is complete it eCom should send a mail to the client, and to my email - But it does not. DW support says all is fine (settings etc...), and it should send this email.

As payment I am using Cart type - "none".
It is the only payment type I am using on the page ("Giro kort" in danish)...
As I am just getting the orderinformation in this event, than saving it in my own database, and eventually export it to the place where client manages their own payments with outside service. It should not do anything tricky.

Kind regards,
Dmitrij


 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
I think you need to uploaded it as a .txt file. .cs files seem to be blocked by the server....

Imar
 
Dmitrij Jazel
Reply
 Allright, here it is... :-)
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
What happens when you debug this code? Does it run OK or are you hitting an exception or catch block somewhere?

Imar
 
Dmitrij Jazel
Reply
Well I actually already am using this code in production, this code runs "perfectly" on the solution so far... Didn't expected any problems from there in general... It is not hitting any exceptions so far, not much to say...
I am not changing any exceptions or anything, I am just logging the exception in the errormessage table as you can see in the code...
The solution application is 8.0.1.3



 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Right; I was just trying to figure out if something in your code causes things to crash which in turn causes no e-mail being sent.

Out of ideas then; hopefully Vladimir has an idea....

Imar
 
Dmitrij Jazel
Reply
Hmm... but If it would cause something to crash (something that I am not capturing or not aware of) shouldn't I get some kind of message like unhandled exception or something of this fashion?
And maybe there is a way to trigger an email with order information, to the emails provided in the ecom module settings, or any other email like custommer email (which I can get from orderobject).
The thing is that if The email is beying send, it must be formated by the template stated in the module settings. This is by far the only workarround I could think of so far...

Kind regards,
Dmitrij
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
shouldn't I get some kind of message like unhandled exception or something of this fashion?
In theory yes, but in Dynamicweb this is often not the case and exceptions might be swallowed.....

Can you make it work without your extender code?

 

Imar

 
Morten Bengtson
Reply
Hi Dmitrij,

Have you tested your SMTP settings? Try to send an e-mail with user info to yourself through user management. If no error occurs then your settings are ok.

Other than that, I have only experienced this when an error occurs in an order template extender (dw swallows the exception, so you will never know what went wrong). You could add a try/catch in all order template extenders and log any exception that is thrown.

In your checkout handler code you have some empty catch blocks. You should probably log the exceptions...
Dynamicweb.LogToFile(exception.ToString(), "CheckoutHandler1", LogType.ManyEntriesPerFile);
This will generate a log file in the folder /Files/System/Log/CheckoutHandler1/

/Morten

 
Martin Nielsen
Reply
 Hi Dmitrij,

We had the same problem a few days back, and we didn't get any errors, but mails didn't get sent.
After looking in the CartV2 event log, we found a line showing an error.

You should be able to find a log in this folder:
\Files\System\Log\eCom\CartV2\Events\LogStarted_2012_XX_XX

And maybe that'll point you in the right direction.
 
Vladimir
Reply
Hi Dmitrij,
sorry for late answer, I was out of office for few days.
The code of your CheckoutHandler actually is looked fine... except that errors are not logged :(
Let's look at cart's log:
\Files\System\Log\eCom\CartV2\Events\LogStarted_2012_XX_XX
(thx Martin)

Best regards,
Vladimir

ps: Is order marked as completed after checkout step?
ps2: there is no way to trigger email directly...


 
Dmitrij Jazel
Reply
 Hej Guys,

Thanks for support :-) really appreciate for all your help here!

I am in the process of trying your solutions here, so I could come up with something that could help me to solve it...
Right now, I have a single order I made here, and The log file surely has the entry...

Here is the log file.(attachment)

In the Shop all orders, if I filter the Order progress as Completed orders - this order is among them, I eventually receive OrderID instead of CartID as I would understood that indicates that the order is completed.
The frontend returns the "Receipt" after checkout. So, it should be fine, but the email is not send. 

I will try to do some more research on the issue, and will come back again with my findings...

Cheers,
Dmitrij
 
Dmitrij Jazel
Reply
Hi guys,
1) I actually tried something that Morten here suggested.
I surrounded the whole method with try/catch and tried to catch the exception.
But there was no exception fired.
Any suggestions here? :-)

2) Regarding mail trigger I came across some stuff on the forum, can this send the mail?
Is it actually usable? or I should do not mind this one?
Dynamicweb.Templatev2.Template tpl = new Dynamicweb.Templatev2.Template(MyTemplatePath);
Dynamicweb.eCommerce.Orders.Order Order = new Dynamicweb.eCommerce.Orders.Order(MyOrderId);
Dynamicweb.eCommerce.Frontend.Renderer Renderer = new Dynamicweb.eCommerce.Frontend.Renderer();
Renderer.RenderOrder(Oder, tlp); // not sure if this one is needed at all.
string MailBody = tpl.Output(); 

The smtp server is registered in /Files/GlobalSettings.aspx. 
You extract the value using Dynamicweb.Base.GetGS("XPath to smtp server node").

Dynamicweb.Base.DefaultSmtpServer
What could you suggest?

Kind regards,
Dmitrij
 
Vladimir
Reply
Hi Dmitrij!
1) About error:
Such error can occur because of mismatch of version number of Dll's references to other component.
Lets find it source:
a) create a handler for CheckoutDoneOrderIsComplete notification with such code
Dynamicweb.LogToFile.Log(Dynamicweb.Frontend.PageView.Current.Execution.getExecutionTable(True), "/CustomErrors", LogToFile.LogType.OneEntryPerFile, True, LogToFile.LogElements.URL)
b) after returning from payment gateway (after CheckoutDoneOrderIsComplete), add to current url new parameter: ?debug=true
first log will stored in Files/System/Log/CustomErrors, second will showed on the screen

2)Email sending
If order details isn't matter:
                    Dim mail As New System.Net.Mail.MailMessage()
                    'Set parameters for MailMessage
                    mail.IsBodyHtml = True
                    mail.Subject = "Subject"
                    mail.SubjectEncoding = System.Text.Encoding.UTF8
                    mail.From = New System.Net.Mail.MailAddress(SenderMail, SenderName, System.Text.Encoding.UTF8)
                    mail.To.Add(RecipientMail)
                    mail.BodyEncoding = System.Text.Encoding.UTF8
                    mail.Body = "..."

                    'Send mail
                    EmailHandler.Send(mail)



Best regards,
Vladimir





 
Dmitrij Jazel
Reply
Hi Vladimir,
Allright, I will try this one aswell, will come back with my findings...

Regards,
Dmitrij

Hi Vladimir,

I just tried to follow your suggestion :-) obviously, to code against correct dll version.
Still no luck... Cause obviously the whole method would have started throwing exceptions if there would be some kind of conflict. But it works, just does not send mail :-)

Regarding this:
2)Email sending
If order details isn't matter:

Well actually it really matters, so I am not sure if this could be the alternative... And what about the template that the mail must have?
As I understood, this one just send mail about the order...

 
Vladimir
Reply
Hi Dmitrij,
sorry, but what about logs - you had got 2 - a log from Files/System/Log/CustomErrors folder and an on screen?

2) To render order detail:
Dynamicweb.Templatev2.Template template = new Dynamicweb.Templatev2.Template(MyTemplatePath);
Dynamicweb.eCommerce.Orders.Order order = new Dynamicweb.eCommerce.Orders.Order(MyOrderId);
Dynamicweb.Frontend.PageView pageView = Dynamicweb.Frontend.PageView.Current();
Dynamicweb.eCommerce.Frontend.Renderer Renderer = new Dynamicweb.eCommerce.Frontend.Renderer(pageView);
Renderer.RenderOrderDetails(template, order, true);
string MailBody = template.Output(); 

Best regards,
Vladimir

 
Dmitrij Jazel
Reply
Hello Vladimir,

I have just tried to do the thing you suggested here.
I still did not managed to receive mail. I am starting to think that there is something wrong with general mail sending on the solution.
I am attaching the log here along with the error file that is being made after the checkout...

Hope we can find how to deal with this one...

Todays date: 14-05-2012

Regards,
Dmitrij
 
Vladimir
Reply
Hi Dmitrij,
the error that happens is: Could not load type 'CheckoutDoneOrderIsCompleteArgs' from assembly 'Dynamicweb, Version=8.0.0.0, Culture=neutral, PublicKeyToken=null'. It not related to mail sending - but it happens just prior mail sending...
Such error as I said can occur because of mismatch of version number of Dll's references to other component. DW logs the libraries that are loaded into project and if you add ?debug=true in url it will show this information. In our case we should do this on the receipt step. I hope this helps to reveal source of problem...

Best regards,
Vladimir



 
Dmitrij Jazel
Reply
Hi Vladimir,

I just tried to update references. Deleted existing references, than downloaded dlls(8.0.1.3) from the website, and made a reference to them (before that I was using reference to DW 8.0.1.5 from DW downloads)

The website DW version is 8.0.1.3.

Still the problem exists.
I am sending you the debug of the receipt and information steps in an excel file.
This time when I have done this, I updated dll's to use websites DLLs version 8.0.1.3 - cause if website is using those dlls than this means it must be this reference I must code against, right?

Here is the log files and debug

Hope it helps... :-(

Dmitrij
 
Vladimir
Reply
you are right ... not want to sound boring, but previously, the site was working on a version 8.0.1.3, and now as I see it is on version 8.0.2.2  (from yesterday)... - this version can be downloaded from http://developer.dynamicweb-cms.com/downloads/dynamicweb-8.aspx  . 
 
Best regards,
Vladimir 
 
ps: thanks for logs
 
Vladimir
Reply
This post has been marked as an answer
Hi Dmitrij,
except that you must specify refferenses similar to websites DLLs (curren 8.0.2.2), In the bin folder of your website should not be DLLs are compiled with older versions of dinamicwveb - at the current time in bin folder of your website there are  Billing.dll and CustomModules.dll. All these dll should either be refreshed or removed

Best regards,
Vladimir

Votes for this answer: 0
 
Vladimir
Reply
Hi Dmitrij,
I found the source of errors:
Dynamicweb.eCommerce.C5Connector.dll  (19kb)

This file was compiled with the old version of Dynamicweb.dll and should be removed or replaced with correct


Best regards,
Vladimir
 
Dmitrij Jazel
Reply
Hi Vladimir,
Thank you very much for this investigation, so this means that Dynamicweb.eCommerce.C5Connector.dll is the source of the trouble?
Well... the current version of the website is 8.0.2.2 - so this has nothing to do with my custom code, and my dlls since those are coded correctly, right?

If that is the case, than I should probably contact Dynamicweb and tell them about it, or get that correct C5Connector.dll and put it into Bin folder?
Should I simply get C5Connector.dll from Application 8.0.2.2 download from dynamicweb site?

Thank you very much for help here,
Really much appreciated ;-)))

Regards,
Dmitrij
 
Vladimir
Reply
Yes with your code all fine, contact  please to the guys from tech support.
C5Connector in my opinion is obsolete and should be removed - and it is absent in latest DW downloads.

Thank you for your kind words :)

Kind regards,
Vladimir
 
Dmitrij Jazel
Reply
Hi Vladimir,

Thanks alot for the help. I will take care of the issue with C5Connector file.

Regarding the references - what references I should use in order to implement Notification subscriber for this checkout:
[Subscribe(Dynamicweb.Notifications.eCommerce.Cart.OrderIsPassedToCheckoutHandler)]
    public class CheckoutHandler3 : NotificationSubscriber

I am currently using this references:
Dynamicweb
Dynamicweb.Admin
Dynamicweb.Controls
Dynamicweb.Data
Dynamicweb.Search

Are there any I should get rid of? Or how can I find that C5Connector.dll is dependent on this specific reference?

Regards,
Dmitrij
 
Vladimir
Reply
Hi Dmitrij,
Refferences are not affect the error
Affects only C5Connector.dll itself.
It is also a NotificationSubscriber and used for integration with  Microsoft Dynamics C5

Best regards,
Vladimir


 
Dmitrij Jazel
Reply
Hi Vladimir,

I just updated the solution to newest Dynamicweb 8.1.0.0
I am not sure but could I ask you how did you check the version of C5Connector.dll?
all I can see is Assembly version: v2.0.50727
and version 1.0.0.0 and that I check when I import a reference to c5connector. When I am building I am not importing or connecting to this file what's so ever...
I used automated update process from dynamicweb admin. After an update, I feel that the issue still exists.

Here are the log files...

Kind regards,
Dmitrij
 
Vladimir
Reply
 Hi Dmitrij!
I suppose that this dll is lays in bin folder and is not updated/replaced with new version.
So if you really do not use integration with Microsoft Dynamics C5, tell support to remove it.
Or... do you have access to the solution folder on server?

Best regards,
Vladimir

 
Dmitrij Jazel
Reply
Hi Vladimir,
Yes I have the access, moved this C5Connector.dll to my machine.
Still the issue remains... But there is no error file generated now... And no exception thrown if I surround the try/catch.
Getting a bit desperate here :-(
I attach the log file. Hope this helps, is there anything else I could to do find out why it might not work?
The emails are setup in the cart module, all should be fine...

Kind regards,
Dmitrij
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
Hi Dmitrij

You still have a lot of dlls in your bin-folder that are compiled against the .NET2.0/3.5 framework. These should be removed. My suggestion would be to simply remove all dlls from the bin-folder and then add the ones from the DW8.1 release, and lastly add your own custom dlls. That way you're sure that no old dlls exist in the bin-folder.

- Jeppe
 
Dmitrij Jazel
Reply
Hi Jeppe, Vladimir,

Thanks again for collaboration on this one.
I finally solved this one...

The solution was:
1) With help of support we cleared all of the dlls and them threw custom ones on the top.
2) Setup cart module with valid email settings: subject, and name etc... all the fields. It seams that if one of the fields is empty the cart wouldn't send the mail even if you enter to email - it still needs subject, name, and from email.

But I think it could be really great to get some notification that those fields are required, and not just throw exceptions :-)

I would really like to thank you guys for all the ideas, and suggestions on regarding the issue.

Kind regards,
Dmitrij
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

You might argue that the Cart paragraph setup should warn you that you haven't entered a valid Sender email address, but that information is present in the log:

[6/7/2012 9:43:42 AM]:	Order XXXXXX: Error: Not a valid Sender Email Address: '' 
See error log for details.


And only the "Template" and "Sender e-mail" fields are required; although it doesn't really make sense to send an order confirmation email and not say who it's from.

- Jeppe

 

You must be logged in to post in the forum