However, it fails with error ''Failure sending mail." when the form is submitted. I am just wonderring if the above code is correct for razor macro? I am new to razor.
As for the error you're getting, make sure that the mail configuration in your web.config is correct. There is some sample configs in the documentation of my package which you could try to test things out.
The first thing I would do is remove the empty Catch block so you can see if there is any SMTP exception being raised. It's generally bad-practice to swallow exceptions without doing anything, too.
Send email in razor macro
Hi, I created a contact form by using razor macro.
However, it fails with error ''Failure sending mail." when the form is submitted. I am just wonderring if the above code is correct for razor macro? I am new to razor.
Thanks
Jamie
You might save yourself a lot of trouble by using my contact mail package for Razor? ;-)
As for the error you're getting, make sure that the mail configuration in your web.config is correct. There is some sample configs in the documentation of my package which you could try to test things out.
Update: Just tested your code and it is fine, so either there's a problem in one of the variables (email, name or telephone), or it's the mail config.
The first thing I would do is remove the empty Catch block so you can see if there is any SMTP exception being raised. It's generally bad-practice to swallow exceptions without doing anything, too.
is working on a reply...