/// <summary> /// To update the jobseeker details /// </summary> /// <param name="id">jobseekerId</param> /// <param name="profile">MGMProfile instance</param> public string Post(MGMProfile profile) { try { //MGMProfile profile = new MGMProfile { email = data.email, firstName = data.firstName, lastName = data.lastName, ageRange = data.ageRange }; MGMProfileService svc = new MGMProfileService(DatabaseFactory.CreateMongoDatabase()); if (svc.ProfileExists(profile.email)) return "The email address has already been registered."; svc.Create(profile); SendEmail(profile.email); return string.Empty; } catch { return "There was a problem saving your information."; } }
private void SendEmail(string to) { System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.Subject = "Email Subject"; msg.From = new System.Net.Mail.MailAddress("*****@*****.**"); msg.To.Add(to); msg.IsBodyHtml = true; msg.Body = "Read this from some file or db entry"; System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("email-smtp.us-east-1.amazonaws.com", 587); client.Credentials = new System.Net.NetworkCredential("AKIAJKQYX4CM6W4RO5HA", "AjJO/eIeBrn2SdJUT5ckqcot6VhMiS6pBawWxtKL8N8c"); client.EnableSsl = true; client.SendCompleted += (s,e) => { if (e.Error == null) { MGMProfileService svc = new MGMProfileService(DatabaseFactory.CreateMongoDatabase()); svc.UpdateEmailStatus(e.UserState.ToString(), true); } client.Dispose(); }; client.SendAsync(msg, to); }