protected void btnGui_Click(object sender, EventArgs e) { try { String email = "*****@*****.**"; String subject = txtChuDe.Text; String body = "Thư được gửi từ" + txtEmail.Text + " với nội dung: " + txtNoiDung.Text; GoogleMail.Send(email, subject, body); MultiView1.ActiveViewIndex = 1; lblHoTen.Text = txtHoTen.Text; lblEmail.Text = txtEmail.Text; lblChuDe.Text = txtChuDe.Text; lblNoiDung.Text = txtNoiDung.Text; } catch (Exception ex) { lblthongbao.Text = "Xảy ra lỗi! " + ex.Message; } }
static public void Send(String To, String Cc, String Bcc, String Subject, String Body, String[] Attachments) { MailMessage Mail = GoogleMail.CreateMailMessage(To, Subject, Body); if (!String.IsNullOrEmpty(Cc)) { Mail.Cc = Cc.Replace(',', ';').Replace(" ", ""); } if (!String.IsNullOrEmpty(Bcc)) { Mail.Bcc = Bcc.Replace(',', ';').Replace(" ", ""); } if (Attachments != null) { foreach (String Attachment in Attachments) { Mail.Attachments.Add(Attachment); } } GoogleMail.Send(Mail); }
static public void Send(String To, String Subject, String Body) { MailMessage Mail = GoogleMail.CreateMailMessage(To, Subject, Body); GoogleMail.Send(Mail); }