Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ben Norman 167 posts 276 karma points
    Jan 30, 2012 @ 23:38
    Ben Norman
    0

    System Errors when sending emails

    Hi Sebastiaan,

    I wanted to put an error message on the page so the user could see their message didn't get through in the event the email was not sent. It looks like your code was written with that in mind.

    I have the following patch for you to consider.

    @@ -112,6 +112,10 @@
                 {
                     Response.Redirect(Page.FormVariables.RedirectUrl);
                 }
    +           else
    +           {
    +               @RenderContactForm()
    +           }
             }
             else
             {
    
    Also, would you consider using the SendMail from the library so that we can get the error in the error log automagically or is that a design choice?
  • Ben Norman 167 posts 276 karma points
    Jan 31, 2012 @ 12:09
    Ben Norman
    0

    Yo Seb,

    Here is another little update for you.

    It helped to have the ex.InnerException replaced with (ex.InnerException ?? ex).Message

    Around line 209 where you have the call to the log, you should probably update it to the following:

                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Error-1string.Format("Error creating or sending contact mail, check if there is a mailFrom property on your document and that it has a value, or specify a MailFrom parameter on the macro call exception: {0}"(ex.InnerException ?ex).Message));
Please Sign in or register to post replies

Write your reply to:

Draft