// email from contact form public void SendContactEmail(Registrant registrant) { emailBody += "NAME: " + registrant.FirstName + " " + registrant.LastName; emailBody += "<br><br>"; emailBody += "EMAIL: " + registrant.Email; emailBody += "<br><br>"; emailBody += "ZIP: " + registrant.ZipCode; emailBody += "<br><br>"; emailBody += "COMMENTS:"; emailBody += "<br><br>"; emailBody += registrant.Comments; var message = new MailMessage(SMTPAddress, contactAddress) { Subject = "Contact Inquiry from Website", IsBodyHtml = true, Body = emailBody }; var mailer = new SmtpClient(); mailer.Host = SMTPHost; mailer.Credentials = new System.Net.NetworkCredential(SMTPAddress, SMTPPassword); mailer.Send(message); return; }
public ActionResult Edit(Registrant registrant) { if (ModelState.IsValid) { db.Registrants.Attach(registrant); db.ObjectStateManager.ChangeObjectState(registrant, EntityState.Modified); db.SaveChanges(); return RedirectToAction("Index"); } return View(registrant); }
public ActionResult Create(Registrant registrant) { if (ModelState.IsValid) { db.Registrants.AddObject(registrant); db.SaveChanges(); return RedirectToAction("Index"); } return View(registrant); }
private void SaveEmail(string email, string fname, string lname, string zip, string ipAddress) { lock (SyncRoot) { string path = Server.MapPath(@"/App_Data/QuickJoins.txt"); bool existed = System.IO.File.Exists(path); using (StreamWriter sw = new StreamWriter(path, true, System.Text.Encoding.UTF8)) { if (!existed) { sw.WriteLine("Email\tFName\tLName\tZip\tIP\tDate"); } if (!Utils.IsValidName(fname)) fname = null; if (!Utils.IsValidName(lname)) lname = null; if (!Utils.IsValidEmail(email)) return; if (!Utils.IsValidZip(zip)) return; int ipCount = 0; if (_IPCount.TryGetValue(ipAddress, out ipCount) && ipCount > _MaxEntriesPerIP) return; _IPCount[ipAddress] = ipCount + 1; string el = email.ToLower().Trim(); if (_SeenEmails.ContainsKey(el)) return; //send email notice MailHandler thisMailer = new MailHandler(); Registrant registrant = new Registrant(); registrant.Email = email; registrant.FirstName = fname; registrant.LastName = lname; registrant.ZipCode = zip; thisMailer.SendContactEmail(registrant, "JOIN"); sw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", email, fname, lname, zip, ipAddress, DateTime.Now.ToString("r")); _SeenEmails[el] = el; sw.Flush(); } } }
// email from contact form public void SendContactEmail(Registrant registrant, string formType) { switch (formType) { case "JOIN": emailSubject = "Join Submission from Website"; JoinHeader = "NEW JOIN MEMBER<br><br>"; break; case "VOLUNTEER": emailSubject = "Volunteer Submission from Website"; VolunteerHeader = "VOLUNTEER INTERESTS:<br><br>"; break; case "CONTACT": emailSubject = "Contact Submission from Website"; ContactHeader = "COMMENTS:<br><br>"; break; default: emailSubject = "Form Submission from Website"; break; } emailBody += JoinHeader; emailBody += "NAME: " + registrant.FirstName + " " + registrant.LastName; emailBody += "<br><br>"; emailBody += "EMAIL: " + registrant.Email; emailBody += "<br><br>"; if (registrant.ZipCode != "") { emailBody += "ZIP: " + registrant.ZipCode; emailBody += "<br><br>"; } emailBody += VolunteerHeader; emailBody += "<br><br>"; emailBody += ContactHeader; emailBody += populateEmailBody(":", registrant.Comments); var message = new MailMessage(SMTPAddress, contactAddress) { Subject = emailSubject, IsBodyHtml = true, Body = emailBody }; var mailer = new SmtpClient(); mailer.Host = SMTPHost; mailer.Credentials = new System.Net.NetworkCredential(SMTPAddress, SMTPPassword); mailer.Send(message); return; }
public ActionResult Index(Registrant registrant) { if (ModelState.IsValid) { db.Registrants.AddObject(registrant); db.SaveChanges(); // send off to NGP NGPAPI thisNGPPoster = new NGPAPI(); thisNGPPoster.postUserToNGP(registrant); return RedirectToAction("ThankYou"); } return View(registrant); }
public ActionResult Index(Registrant registrant) { if (ModelState.IsValid) { db.Registrants.AddObject(registrant); db.SaveChanges(); MailHandler thisMailer = new MailHandler(); thisMailer.SendContactEmail(registrant); return RedirectToAction("ThankYou"); } return View(registrant); }
public void postUserToNGP(Registrant registrant) { string MyRequest = "<lastName>" + registrant.LastName + "</lastName>"; MyRequest = MyRequest + "<firstName>" + registrant.FirstName + "</firstName>"; MyRequest = MyRequest + "<email>" + registrant.Email + "</email>"; MyRequest = MyRequest + "<zip>" + registrant.ZipCode + "</zip>"; //credentials string strCredentials = ConfigurationManager.AppSettings["NGPJoinToken"]; //url string url = ConfigurationManager.AppSettings["NGPURL"]; // //create the soap envelope and add request to it string Post = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"; Post = Post + " xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"; Post = Post + "<soap:Body><EmailSignUp xmlns='http://ngpsoftware.com/NGP.Services.UI/OnlineContribService'>"; Post = Post + "<credentials>" + strCredentials + "</credentials>" + MyRequest + " <SendEmail>true</SendEmail></EmailSignUp>"; Post = Post + "</soap:Body></soap:Envelope>"; string SOAPAction = "http://ngpsoftware.com/NGP.Services.UI/OnlineContribService/EmailSignUp"; // Create a request using a URL that can receive a post. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. string postData = Post; byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest. request.ContentType = "text/xml; charset=utf-8"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // add SoapAction Header request.Headers.Add("SOAPAction:" + SOAPAction); // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); // Get the response. HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // log the content. //var fileName = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, @"LOGS\NGP.LOG"); //byte[] result = null; //int byteCount = Convert.ToInt32(response.ContentLength); //using (BinaryReader reader = new BinaryReader(response.GetResponseStream())) //{ // result = reader.ReadBytes(byteCount); // reader.Close(); //} //// log the content. //Utils.SaveStreamToFile(result, fileName); //Utils.SaveToFile(response.GetResponseStream().ToString(), fileName); //Utils.SaveToFile(response.Headers.ToString(), fileName); //Utils.SaveToFile(response.StatusDescription, fileName); // Clean up the streams. response.Close(); return; }
/// <summary> /// Deprecated Method for adding a new object to the Registrants EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRegistrants(Registrant registrant) { base.AddObject("Registrants", registrant); }
/// <summary> /// Create a new Registrant object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="zipCode">Initial value of the ZipCode property.</param> public static Registrant CreateRegistrant(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String email, global::System.String zipCode) { Registrant registrant = new Registrant(); registrant.Id = id; registrant.FirstName = firstName; registrant.LastName = lastName; registrant.Email = email; registrant.ZipCode = zipCode; return registrant; }
/// <summary> /// Create a new Registrant object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="comments">Initial value of the Comments property.</param> public static Registrant CreateRegistrant(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String email, global::System.String comments) { Registrant registrant = new Registrant(); registrant.Id = id; registrant.FirstName = firstName; registrant.LastName = lastName; registrant.Email = email; registrant.Comments = comments; return registrant; }