Exception in template (Designs\CrossControl\Paragraph\_downloadHandler.cshtml): System.ArgumentNullException: Value cannot be null.
Parameter name: to
   at System.Net.Mail.MailMessage..ctor(String from, String to)
   at CompiledRazorTemplates.Dynamic.bccbcbfbdab.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System @using System.IO @using System.Net.Mail @using System.Web @using Dynamicweb; @using Dynamicweb.Modules.UserManagement @{ var fileName = Base.Request("fileName"); var firstName = Base.Request("firstname"); var lastName = Base.Request("lastname"); var email = Base.Request("email"); var company = Base.Request("company"); var phone = Base.Request("phone"); var mailBody = ""; var mailMessage = new MailMessage("noreply@crosscontrol.com", email); var attachmentPath = HttpContext.Current.Server.MapPath(string.Format("{0}", fileName)); var attachment = new Attachment(attachmentPath); //mailBody += string.Format("Hej {0}<br/><br/>", name); mailBody += "Thank you for showing interest in CrossControl!<br/><br/>Please find attached the requested download.<br/>If you have questions, please reach out to <a href='mailto:info@crosscontrol.com'>info@crosscontrol.com</a> or <a href='mailto:sales@crosscontrol.com'>sales@crosscontrol.com</a><br/>"; mailMessage.Body = mailBody; mailMessage.Subject = "Thanks for showing interest in CrossControl!"; mailMessage.IsBodyHtml = true; mailMessage.From = new MailAddress("noreply@crosscontrol.com"); mailMessage.Attachments.Add(attachment); EmailHandler.Send(mailMessage); var u = new User { FirstName = firstName, LastName = lastName, Name = string.Format("{0} {1}", firstName, lastName), Email = email, Phone = phone, Company = company, UserName = email }; u.AddToGroup(362); u.Save(); }