public ActionResult NewApplication(TestInfo testInfo) { string response = ""; if (ModelState.IsValid) { response = new RegisterRepository().RegisterTest(testInfo); MailMessage message = new MailMessage(); string username = "******"; string password = "******"; string receiverEmail = testInfo.StudentInfo.AddressInfo.Email; ContentType mimeType = new ContentType("text/html"); AlternateView alternate = AlternateView.CreateAlternateViewFromString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"> <html><head><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\"></head><body><b>Dear " + testInfo.StudentInfo.FirstName + testInfo.StudentInfo.LastName + "</b>, <br /><br /><br />Greetings from IELTS !!! <br/><br/><br/> Your registration was successful. Thank You for registering IELTS Examination. <br/> <br/> <br/> Please see below the registration details <br/> <b> Your Receipt Number :</b> " + testInfo.ReceiptNumber + ".<br /><b> Registered Date Time :</b> " + testInfo.CreatedDate.ToString() + "<br /><br /> <b>Note: </b> Receipt Number and Passport or National Identity Card is mandatory to check your test results. <br /><br /><br /> Thank You,<br/><br/><br/> IELTS Admin</body></html>.", mimeType); message.From = new MailAddress(username); message.To.Add(receiverEmail); message.Subject = "IELTS Registration - Congrats, " + testInfo.StudentInfo.FirstName + " " + testInfo.StudentInfo.LastName + "!"; //message.Body = "<html><head></head><body><b>Dear " + testInfo.StudentInfo.FirstName + testInfo.StudentInfo.LastName + "</b>, <br /><br /><br />Greetings from IELTS !!! <br/> Your registration was successful. Thank You for registering IELTS Examination. <br/> Please see below the registration details <br/> <dd /><b>Your Receipt Number :</b> " + testInfo.ReceiptNumber + ".<br /><dd /><b>Registered Date Time :</b> "+testInfo.CreatedDate.ToString()+"<br /><br /> <b>Note: </b> Receipt Number is mandatory to check your test results. <br /><br /><br /> Thank You, IELTS Admin</body></html>."; message.AlternateViews.Add(alternate); message.IsBodyHtml = true; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587); smtpClient.EnableSsl = true; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(username, password); smtpClient.Send(message); RedirectToAction("SubmitApplicationForm"); } return View(testInfo); }
public static TestInfo CreateJunkData() { try { address = new AddressInfo() { AddressI="Address1",AddressII="Address II",Email="*****@*****.**",MobilePhone="12121212",Telephone="123123123",ZipOrPostalCode="123123",FK_TestInfoID=null}; office = new OfficeUse() { AC=true,AdministratorInitials="AC",DateofPayment=DateTime.Now,GT=true,IDChecked=true,ReceiptNumber="guid",Scheme="Scheme",TestDate=DateTime.Now}; student = new StudentInfo() { AddressInfo=address, ApplyingCountry = "AC", CountryNationalCode = "NC01", DateOfBirth = DateTime.Now,EducationLevel="EL01",EnglishLearningLocation="UK",EnglishLearningPeriod="5",FirstLanguageCode="01",FirstName="Madhu",Gender="Male",LastName="LNAME",OccupationLevel="01",OccupationSector="02",PermanentDisability="No",Title="Title" }; tinfo = new TestInfo() { OfficeUse=office, StudentInfo=student, TestReason = "Reason", TestModule = "Module", TestCityLocation = "UAE", Status = 0, ResultCopyTo = true, CreatedDate = DateTime.Now, ModifiedDateTime = DateTime.Now, PreferredTestDate = DateTime.Now, ReceiptNumber = "RECEIPTMENT", SecondaryTestDate = DateTime.Now }; add1 = new AddressInfo() { AddressI = "Address1", AddressII = "Address II", Email = "*****@*****.**", MobilePhone = "12121212", Telephone = "123123123", ZipOrPostalCode = "123123",TestInfo=tinfo }; add2 = new AddressInfo() { AddressI = "Address1", AddressII = "Address II", Email = "*****@*****.**", MobilePhone = "12121212", Telephone = "123123123", ZipOrPostalCode = "123123", TestInfo = tinfo }; return tinfo; } catch (Exception ex) { throw ex; } }