private void sendEmail(SendFriendRequest data) { var message = new MailMessage { From = new MailAddress("*****@*****.**"), Subject = "Invite to see some health values", Body = string.Format( "Hi, you are invited to see this an health profile. Click on this link to see the profile http://www.myselflog.com/profile/{0}", data.LogProfileId) }; message.To.Add(data.Email); var client = new SmtpClient(); // send credentials if your SMTP server requires them //client.Credentials = new NetworkCredential("user", "password"); client.Send(message); //var mail = new MailMessage("EmailFrom", data.Email); //const string sendtoBcc = "*****@*****.**"; //mail.Bcc.Add(sendtoBcc); //mail.Subject = "Subject"; //mail.IsBodyHtml = true; //mail.Body = // string.Format( // "Hi, you are invited to see this an health profile. Click on this link to see the profile http://www.myselflog.com/profile/{0}", // data.LogProfileId); //// send the message //var smtp = new SmtpClient(); //smtp.Send(mail); //// - See more at: http://blog.arvixe.com/send-email-using-jquery-and-web-api-part-2/#sthash.8AVABG12.dpuf }
public HttpResponseMessage Post([FromBody] SendFriendRequest data) { sendEmail(data); return(Request.CreateResponse(HttpStatusCode.OK, "message sent")); }