public string SenderMail(tblMail mail) { SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.Host = "smtp.gmail.com"; client.Port = 587; System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("*****@*****.**", "GoMo13#$"); client.UseDefaultCredentials = false; client.Credentials = credentials; MailMessage msg = new MailMessage(); msg.From = new MailAddress(mail.sEmail); msg.To.Add(new MailAddress("*****@*****.**")); msg.Subject = "Enquire about a property"; msg.IsBodyHtml = true; msg.Body = string.Format("<html><head><head><body><b> Name: </ b > " + mail.sender + " < br/>< br/> " + " <b> Email: </b > " + mail.sEmail + " <br/>< br/> " + " <b> Mobile Number: </b > " + mail.senderContact + " < br/>< br/> " + mail.messages + " </body></html> "); try { client.Send(msg); return("Email has been sent"); } catch (Exception ex) { return("An error:" + ex.ToString() + "occured"); } }
public IHttpActionResult PuttblMail(int id, tblMail tblMail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblMail.Id) { return(BadRequest()); } db.Entry(tblMail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblMailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GettblMail(int id) { tblMail tblMail = db.tblMails.Find(id); if (tblMail == null) { return(NotFound()); } return(Ok(tblMail)); }
public IHttpActionResult PosttblMail(tblMail tblMail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tblMails.Add(tblMail); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblMail.Id }, tblMail)); }
public IHttpActionResult DeletetblMail(int id) { tblMail tblMail = db.tblMails.Find(id); if (tblMail == null) { return(NotFound()); } db.tblMails.Remove(tblMail); db.SaveChanges(); return(Ok(tblMail)); }