public HttpResponseMessage Sendmail([FromBody] mail value) { result <object> tel = new result <object>(); try { SmtpClient mailclient = new SmtpClient("smtp.gmail.com", 587); mailclient.EnableSsl = true; mailclient.Credentials = new NetworkCredential("*****@*****.**", "duytuit89!"); MailMessage message = new MailMessage("*****@*****.**", value.to); message.Subject = value.subject; message.Body = value.bobdy; mailclient.Send(message); tel.code = "OK"; tel.mess = "Đã gửi thư thành công..."; } catch (Exception df) { tel.code = "ERR"; tel.mess = df.Message; } return(tel.ToHttpResponseMessage()); }
protected void btnsend_Click(object sender, EventArgs e) { if (txtEmail.Text != "" && txtMessege.Text != "" && txtSubject.Text != "") { mail m = new mail(); if (m.SendMail(txtEmail.Text, txtSubject.Text, txtMessege.Text)) { lblResult.Text = "Messege Send."; txtSubject.Text = ""; txtMessege.Text = ""; txtEmail.Text = ""; } else { lblResult.Text = "Messege Not Send."; txtSubject.Text = ""; txtMessege.Text = ""; txtEmail.Text = ""; } } else { lblResult.Text = "Fill all Froms."; } }
private void btnSave_Click(object sender, EventArgs e) { if (txtOldPassword.Text == MainForm._employee.Password && txtNewPassword.Text == txtNewPasswordAgain.Text) { MainForm._employee.Password = txtNewPassword.Text; if (_employeeBLL.Update(MainForm._employee)) { mail mail = new mail(); if (mail.SentMail( MainForm._employee.EMail, "Şifre Güncelleme", string.Format( "Sayın : {0}\nSisteme yeni giriş bilgileriniz aşşağıda verilmiştir. \n\nŞifreniz: {1}\n\n\nİyi Çalışmalar...\n\n\nBlack Group" , MainForm._employee.FullName, txtNewPassword.Text ))) { MessageBox.Show("Şifreniz güncellenmiştir. \nBilgileriniz mail adresinize gönderildi"); } } else { MessageBox.Show("Güncelleme işlemi başarısız oldu"); } } else { MessageBox.Show("Eski şifrenizi doğru birşekilde giriniz veya Girilen şifreler eşleşmiyor"); } }
public bool SendLodgementReimbursementMail(shop shop, mail mail, master_transaction tran) { try { admin_user user = new CRUD.admin_users_crud().find_admin_user_By_ID(shop.agent.Value); string body = mail.content; if (user != null && user.email != "" && user.email != string.Empty && user.email != null) { string accountName = ((user.firstname != null) ? user.firstname.ToUpperInvariant() : "") + " " + ((user.middlename != null) ? user.middlename.ToUpperInvariant() : "") + " " + ((user.lastname != null) ? user.lastname.ToUpperInvariant() : ""); string balance = ""; if (shop.master_balance_sheets != null && shop.master_balance_sheets.Count > 0) { balance = tran.amount.ToString(); } body = body.Replace("{shop_code}", shop.shop_code); body = body.Replace("{account_name}", (accountName != null) ? accountName : "UNAVAILABLE"); body = body.Replace("{amount}", balance); body = body.Replace("{curr_debt_bal}", tran.balance_after.ToString()); body = body.Replace("{bank_acct}", getbankaccounts()); SendBulkMail(user.email, mail.name, body); return(true); } return(false); } catch (Exception) { return(false); } }
public async Task <IActionResult> Edit(int id, [Bind("mailID,mailAdress")] mail mail) { if (id != mail.mailID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!mailExists(mail.mailID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mail)); }
public HttpResponseMessage Sendmail([FromBody] mail value) { result <object> tel = new result <object>(); try { SmtpClient mailclient = new SmtpClient(value.server, value.port); mailclient.EnableSsl = true; mailclient.Credentials = new NetworkCredential(value.user, value.pass); MailMessage message = new MailMessage("*****@*****.**", value.to); message.Subject = value.subject; message.Body = value.bobdy; mailclient.Send(message); tel.code = "OK"; tel.mess = "Đã gửi thư thành công..."; } catch (Exception df) { tel.code = "ERR"; tel.mess = df.Message; } return(tel.ToHttpResponseMessage()); }
public async Task <IActionResult> Create([Bind("mailID,mailAdress")] mail mail) { if (ModelState.IsValid) { _context.Add(mail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mail)); }
public void Post([FromBody] User u) { if (u.userKod != 0) { p.addUserForGetMail(u); } else { mail email = new mail(); try { var fromAddress = new MailAddress("*****@*****.**", "From Name"); var toAddress = new MailAddress(u.mail, "To Name"); const string fromPassword = "******"; const string subject = "מייל מאתר השבת אבידה"; string body = null; //city=שאלה לרב Tel2= massage if (u.city != null) { body = u.city; } else { body = u.Tel2; } var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } } catch (Exception ex) { //return ex.ToString(); } } } // PUT: api/user/5
public mail find_mail_By_ID(int id) { try { mail = db.mails.SingleOrDefault(a => a.id == id); return(mail); } catch (Exception) { return(null); } }
public mail delete_mail() { try { mail prev_mail = db.mails.SingleOrDefault(a => a.id == mail.id); db.mails.DeleteOnSubmit(prev_mail); return(mail); } catch (Exception) { return(null); } }
public ViewResult Index(mail objModelMail, HttpPostedFileBase fileUploader) { if (ModelState.IsValid) { MailMessage mail = new MailMessage(); mail.To.Add(objModelMail.To); mail.From = new MailAddress(objModelMail.From); mail.Subject = objModelMail.Subject; string Body = objModelMail.Body; String password = objModelMail.Password; mail.Body = Body; if (fileUploader != null) { string fileName = Path.GetFileName(fileUploader.FileName); mail.Attachments.Add(new Attachment(fileUploader.InputStream, fileName)); } mail.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential networkCredential = new NetworkCredential(mail.From.ToString(), password); smtp.UseDefaultCredentials = true; smtp.Credentials = networkCredential; smtp.Port = 587; smtp.Send(mail); ViewBag.Message = "Sent"; return(View("Index", objModelMail)); } else { return(View()); } }
public ActionResult enviar_soporte(modelo_datos_soporte nuevo_soporte) { mail m = new mail(); // byte[] data = new byte[nuevo_soporte.fotos.ContentLength]; // nuevo_soporte.fotos.InputStream.Read(data, 0, nuevo_soporte.fotos.ContentLength); //nuevo_soporte.foto_soporte = data; //m.enviar_correo(nuevo_soporte.foto_soporte, nuevo_soporte.correo_remitente, 0); //m.Correo_Soporte(nuevo_soporte.correo_remitente, nuevo_soporte.nombre_remitente, nuevo_soporte.rut_remitente, nuevo_soporte.asunto_mensaje, nuevo_soporte.descripcion_mensaje, nuevo_soporte.foto_soporte); return(View("index")); }
public ActionResult Test2() { var entry = new mail { toName = "sean lin", toEmail = "*****@*****.**", subject = "test", body = "test", reference = "" }; Email.Email.SendMail(entry, true, true); return(Content("done")); }
public ActionResult Iletisim(string name, string mail, string phone, string message) { mail m = new mail(); m.CreatedDate = DateTime.Now; m.Email = mail; m.Name = name; m.Phone = phone; m.Type = "Web Site Mesajı : " + message; db.mails.Add(m); db.SaveChanges(); ViewBag.Mesaj = " * Mesajınız Alınmıştır. En Kısa sürede geri dönüş yapılacaktır."; return(View()); }
/// <summary> /// /// </summary> /// <param name="toName"></param> /// <param name="toEmail"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <param name="owner"></param> /// <param name="queueMail"> </param> /// <param name="cclist"> </param> public static void SendMail(string toName, string toEmail, string subject, string body, bool queueMail, IEnumerable <string> cclist) { if (toName == null) { toName = ""; } var entry = new mail { toName = toName, toEmail = toEmail, subject = subject, body = body }; SendMail(entry, true, queueMail, cclist); }
public void KazanmakIcin(string name, string phone, DateTime?dt, string mail, string job, string city, string nereden, string type) { mail m = new mail(); m.Birthday = dt; m.City = city; m.CreatedDate = DateTime.Now; m.Email = mail; m.Job = job; m.Name = name; m.Nereden = nereden; m.Phone = phone; m.Type = type; db.mails.Add(m); db.SaveChanges(); }
private void btnCreatWork_Click(object sender, EventArgs e) { _work.WorkDetail = txtWorkDetail.Text; _work.ProjectID = (cmbProject.SelectedValue != null)?(int)cmbProject.SelectedValue:0; if (cmbEmployee.SelectedValue != null) { _work.EmployeeID = (int)cmbEmployee.SelectedValue; } _work.ManagerID = MainForm._employee.ID; DateTime date = new DateTime(DateTime.Now.Date.Year, DateTime.Now.Date.Month, DateTime.Now.Date.Day); _work.CreationDate = date; _work.WorkStatusID = 1; if (_workBLL.Add(_work)) { mail mail = new mail(); if (_work.EmployeeID != null) { _work.Employee = _employeeBLL.Get((int)cmbEmployee.SelectedValue); if (mail.SentMail(_work.Employee.EMail, "Yeni Atanan iş", MainForm._employee.FullName + " tarafından size iş tanımlanmıştır. \n\n\nİyi çalışmalar dileriz. \n\nBlack Group :)")) { MessageBox.Show("İş oluşturuldu sistem çalışana mail gönderdi"); if (_newRequestToWork != null) { _newRequestToWork.State = false; RequestBLL requestBLL = new RequestBLL(); if (requestBLL.Update(_newRequestToWork)) { this.Close(); } } } } else { MessageBox.Show("İş oluşturuldu işe çalışan atanmadı"); } } else { MessageBox.Show("Hata meydana geldi"); } }
public mail alter_mail() { try { mail prev_mail = db.mails.SingleOrDefault(a => a.id == mail.id); prev_mail.description = mail.description; prev_mail.name = mail.name; prev_mail.content = mail.content; db.SubmitChanges(); return(mail); } catch (Exception) { return(null); } }
static void Main(string[] args) { mail m = new mail(@"W:\NIKKI\config.xml"); string body = string.Empty; body = "<html><body><h1>Picture</h1><br><img src=\"cid:img0\"></body></html>"; m.linksources.Add(@"C:\Users\lmallado\Pictures\Collateral_AUTO.PNG"); m.mailto.Add("*****@*****.**"); m.mailcc.Add("*****@*****.**"); if (!m.sendHMail(body, "Test")) { Console.WriteLine(m.ErrorMessage); } //Console.ReadKey(); //string xmldir = @"W:\"; //logger log = new logger(xmldir,"IImplementation"); ////String xmlpath = @"W:\NIKKI\config.xml"; //while (true) //{ // if (DateTime.Now.ToString("ss").EndsWith("0")) // { // log.writeToLog("Triggering for :" + DateTime.Now.ToString("ss"), "Everything is smooth"); // //using (mail mail = new mail(xmlpath)) // //{ // // mail.mailto.Add("*****@*****.**"); // // mail.mailcc.Add("*****@*****.**"); // // if (!mail.sendMail("Hi there", "Test")) // // { // // Console.WriteLine(mail.ErrorMessage); // // } // // else // // { // // Console.WriteLine("Done"); // // } // //} // System.Threading.Thread.Sleep(5000); // } //} }
public static void SendMail(string toName, string toEmail, string subject, string body, user sender, bool queueMail) { if (toName == null) { toName = ""; } var entry = new mail { fromName = sender == null ? "tradelr.com": sender.organisation1.name, fromEmail = sender == null ? "" : sender.ToEmail(), toName = toName, toEmail = toEmail, subject = subject, body = body, reference = sender == null ? "": sender.id.ToString() }; SendMail(entry, true, queueMail); }
protected void Button1_Click(object sender, EventArgs e) { ds.Clear(); string e_key = db.extscalr("select ekey from tb_upload where fname='" + Session["fn"].ToString() + "'"); enc_string = cld.encrypt(TextBox1.Text, e_key); string enc_path = Server.MapPath("~/Employee/files/efile/" + Session["fn"].ToString() + ".txt"); File.WriteAllText(enc_path, enc_string); bool b = db.extnon("update tb_upload set e_status='2',date ='" + DateTime.Now.ToString() + "' where fname='" + Session["fn"].ToString() + "'"); if (b == true) { List <string> ls = new List <string>(); ds.Clear(); ds = db.discont("select roles from tb_role_policy where filename='" + Session["fn"].ToString() + "'"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ls.Add(ds.Tables[0].Rows[i]["roles"].ToString()); } for (int i = 0; i < ls.Count; i++) { ds.Clear(); ds = db.discont("select role from tb_login where role='" + ls[i].ToString() + "'"); if (ds.Tables[0].Rows.Count > 0) { mail ma = new mail(); ma.send_msg(" File modified :", Session["fn"].ToString()); break; } } TextBox1.Text = null; RegisterStartupScript("", "<script Language=JavaScript>alert('Successfully Uploaded')</Script>"); } }
public ActionResult creators(string content, string subject) { content = HttpUtility.HtmlDecode(content); subject = HttpUtility.HtmlDecode(subject); var users = db.users.Where(x => (x.role & (int)UserRole.CREATOR) != 0); foreach (var user in users) { var email = user.email; var mail = new mail { fromEmail = Email.Email.MAIL_SOURCE_ADDRESS, fromName = "tradelr", body = content, subject = subject, toEmail = email, toName = string.IsNullOrEmpty(user.ToFullName())? "": user.ToFullName() }; Email.Email.SendMail(mail, false, true); } return(Json("".ToJsonOKData())); }
// ----------------------------------------------------------------------------------- // Sqlite Mail_BuildMessageFromDBRow // ----------------------------------------------------------------------------------- public MailMessage Mail_BuildMessageFromDBRow(mail row) { MailMessage message = new MailMessage(); message.id = row.id; message.from = row.messageFrom; message.to = row.messageTo; message.subject = row.subject; message.body = row.body; message.sent = row.sent; message.expires = row.expires; message.read = row.read; message.deleted = row.deleted; string item = row.item; if (ScriptableItem.dict.TryGetValue(item.GetDeterministicHashCode(), out ScriptableItem itemData)) { message.item = itemData; } return(message); }
// ----------------------------------------------------------------------------------- // // ----------------------------------------------------------------------------------- public MailMessage Mail_BuildMessageFromDBRow(mail row) { MailMessage message = new MailMessage { id = row.id, @from = row.messageFrom, to = row.messageTo, subject = row.subject, body = row.body, sent = row.sent, expires = row.expires, read = row.read, deleted = row.deleted }; string name = row.item; if (ScriptableItem.dict.TryGetValue(name.GetStableHashCode(), out ScriptableItem itemData)) { message.item = itemData; } return(message); }
private void btnEmployeeAdd_Click(object sender, EventArgs e) { if (txtFirstName.Text != string.Empty && txtLastName.Text != string.Empty && txtMail.Text != string.Empty && txtPassword.Text != string.Empty) { if (_updateEmployee == null) { int pass = rnd.Next(10000000, 99999999); employee.FirstName = txtFirstName.Text; employee.LastName = txtLastName.Text; employee.PositionID = (int)cmbPosition.SelectedValue; employee.EMail = txtMail.Text; employee.Password = pass.ToString(); if (employeeBLL.Add(employee)) { mail mail = new mail(); if (mail.SentMail(txtMail.Text, "Aramıza hoşgeldiniz", string.Format( "Değerli çalışanımız : {0}\n\nBizimle olmanızdan dolayı mutluyuz\n\nSistemi kullanmak için bilgileriniz : \n\nMail Adres:{1}\nParola : {2}\n\n\n\nİyi Çalışmalar dileriz\n\nBlack Group" , employee.FullName, employee.EMail, employee.Password ))) { MessageBox.Show("Çalışan kaydı oluşturuldu bilgiler çalışan mail adresine gönderildi"); } } else { MessageBox.Show("Kayıt Ekleme Başarısız"); } } else { _updateEmployee.FirstName = txtFirstName.Text; _updateEmployee.LastName = txtLastName.Text; _updateEmployee.PositionID = (int)cmbPosition.SelectedValue; _updateEmployee.EMail = txtMail.Text; _updateEmployee.Password = txtPassword.Text; if (employeeBLL.Update(_updateEmployee)) { MessageBox.Show("Güncelleme başarılı"); } else { MessageBox.Show("Güncelleme işlemi başarısız"); } } bool control = true; foreach (var item in MdiParent.MdiChildren) { if (item is EmployeeListForm) { ((EmployeeListForm)item).EmployeeList(); item.BringToFront(); control = false; } } if (control) { EmployeeListForm employeeList = new EmployeeListForm(); employeeList.MdiParent = MdiParent; employeeList.Show(); } } else { MessageBox.Show("Boş Alan Bırakmayınız!"); } }
public mailbuilder(string sender, string receiver) { obj = new mail(); obj.sender = sender; obj.receiver = receiver; }
public ActionResult Contact(mail mail) { db.mails.Add(mail); db.SaveChanges(); return(RedirectToAction("/")); }
public void DeleteMail(mail entry) { db.mails.DeleteOnSubmit(entry); }
/// <summary> /// /// </summary> /// <param name="entry"></param> /// <param name="isAsync"></param> /// <param name="repository">if specified, email is queued</param> public static void SendMail(mail entry, bool isAsync, bool queueMail) { // need to check for invalid email address if (!entry.toEmail.IsEmail()) { return; } if (queueMail) { // queue it instead using (var db = new tradelrDataContext()) { db.mails.InsertOnSubmit(entry); db.SubmitChanges(); } return; } var from = new MailAddress(MAIL_SOURCE_ADDRESS, "tradelr", Encoding.UTF8); MailAddress replyto = null; if (!string.IsNullOrEmpty(entry.fromEmail)) { replyto = new MailAddress(entry.fromEmail, entry.fromName, Encoding.UTF8); } else { entry.fromEmail = MAIL_SOURCE_ADDRESS; entry.fromName = "tradelr"; } var to = new MailAddress(entry.toEmail, entry.toName, Encoding.UTF8); var msg = new MailMessage(from, to) { Body = entry.body, IsBodyHtml = true, BodyEncoding = Encoding.UTF8, Subject = entry.subject, SubjectEncoding = Encoding.UTF8 }; if (replyto != null) { msg.ReplyToList.Add(replyto); } #if DEBUG var smtp = new SmtpClient(MAIL_SERVER, 587) { EnableSsl = true }; var cred = new NetworkCredential("*****@*****.**", MAIL_PASSWORD); //smtp.Timeout = 10000; #else SmtpClient smtp = new SmtpClient(MAIL_SERVER); NetworkCredential cred = new NetworkCredential(MAIL_SOURCE_ADDRESS, MAIL_PASSWORD); #endif new Thread(() => { smtp.Credentials = cred; if (isAsync) { smtp.SendCompleted += SendCompletedCallback; smtp.SendAsync(msg, entry); } else { try { smtp.Send(msg); } catch (Exception ex) { Syslog.Write(ex); } } }).Start(); }
/// <summary> /// /// </summary> /// <param name="entry"></param> /// <param name="isAsync"></param> /// <param name="queueMail"></param> /// <param name="ccList"></param> public static void SendMail(mail entry, bool isAsync, bool queueMail, IEnumerable <string> ccList = null) { // need to check for invalid email address if (!entry.toEmail.IsEmail()) { return; } if (queueMail) { // queue it instead using (var db = new ioschoolsDBDataContext()) { db.mails.InsertOnSubmit(entry); db.SubmitChanges(); } return; } var from = new MailAddress(MAIL_SOURCE_ADDRESS, " School", Encoding.UTF8); MailAddress replyto = null; if (!string.IsNullOrEmpty(entry.fromEmail)) { replyto = new MailAddress(entry.fromEmail, entry.fromName, Encoding.UTF8); } var to = new MailAddress(entry.toEmail, entry.toName, Encoding.UTF8); var msg = new MailMessage(from, to) { Body = entry.body, IsBodyHtml = true, BodyEncoding = Encoding.UTF8, Subject = entry.subject, SubjectEncoding = Encoding.UTF8 }; // add footer if (replyto != null) { msg.ReplyTo = replyto; msg.Body += "<p>You can directly reply to this email.</p>"; } else { msg.Body += "<p>This is an automated mail. Please DO NOT reply to this email.</p>"; } // cclist if (ccList != null) { foreach (var email in ccList) { msg.CC.Add(new MailAddress(email)); } } var smtp = new SmtpClient(MAIL_SERVER) { Credentials = new NetworkCredential(MAIL_SOURCE_ADDRESS, MAIL_PASSWORD) }; if (isAsync) { smtp.SendCompleted += SendCompletedCallback; smtp.SendAsync(msg, entry); } else { try { smtp.Send(msg); } catch (SmtpFailedRecipientException ex) { Syslog.Write(ex); } catch (Exception ex) { Syslog.Write(ex); // then we need to reinsert back // reinsert back into database using (var db = new ioschoolsDBDataContext()) { db.mails.InsertOnSubmit(entry); db.SubmitChanges(); } } } }