//public string GetData(int value) //{ // return string.Format("You entered: {0}", value); //} //public CompositeType GetDataUsingDataContract(CompositeType composite) //{ // if (composite == null) // { // throw new ArgumentNullException("composite"); // } // if (composite.BoolValue) // { // composite.StringValue += "Suffix"; // } // return composite; //} public void SendEmails(Models.Email eMail, Models.EmailAccount emailAccount = null) { try { string pass = "******"; string correo = "*****@*****.**"; SmtpClient SmtpServer = new SmtpClient("smtp.live.com"); var mail = new MailMessage(); mail.From = new MailAddress(correo); eMail.To.ForEach(To => mail.To.Add(To.Account));// eMail.CC.ForEach(CC => mail.CC.Add(CC.Account)); //eMail.Attachments.ForEach(itemAttachment => mail.Attachments.Add(itemAttachment)); mail.Subject = eMail.Subject; mail.IsBodyHtml = true; var firmaHtml = eMail.Singature; mail.Body = eMail.Body; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential((string.IsNullOrEmpty(eMail.From.Account) ? correo : eMail.From.Account), (string.IsNullOrEmpty(eMail.From.Password) ? pass : eMail.From.Password)); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } catch (Exception ex) { Console.WriteLine("SendEmailCertificate - Ha ocurrido un error en el servicio: " + ex.Message); throw; } }
public void RecordarContraseña(Ent_ttccol300 ParametrosIn, ref string strError) { method = MethodBase.GetCurrentMethod(); paramList = new Dictionary <string, object>(); paramList.Add("p1", ParametrosIn.user); strSentencia = recursos.readStatement(method.ReflectedType.Name, method.Name, ref owner, ref env, tabla, paramList); try { consulta = DAL.BaseDAL.BaseDal.EjecutarCons("Text", strSentencia, ref parametersOut, null, true); if (consulta.Rows.Count < 1) { strError = "-1"; } Ent_ttccol300 obj = new Ent_ttccol300(); SendMailService.SendMailService SendMail = IntanciaServicionSendMail(); foreach (DataRow item in consulta.Rows) { obj.pass = item["pswd"].ToString(); obj.nama = item["Nombre"].ToString(); obj.user = item["userN"].ToString(); obj.ufin = item["UFIN"].ToString(); obj.role = Convert.ToInt32(item["role"]); obj.shif = item["shif"].ToString(); } SendMailService.Models.Email Email = new SendMailService.Models.Email(); Email.Body = "Name: " + obj.nama + "User: "******"Password: "******"*****@*****.**" }); Email.To = LstTo; Email.Subject = "Password recovery : " + obj.user; SendMail.SendEmails(Email); //SendMail.SendEmails(); } catch (Exception ex) { //Comentado CChaverra 11052017 strError = "Error when querying data [ttccol300]. Try again or contact your administrator"; strError = ex.InnerException != null ? ex.Message + " (" + ex.InnerException + ")" : ex.Message; throw ex; } }