Ejemplo n.º 1
0
 protected void SendMAil()
 {
     try
     {
         if (txtMailTo.Text != "")
         {
             objNotes      = new NotesClass();
             objNotes.User = Request.QueryString["user"];
             DataTable   dtUserMail = objNotes.GetEmployeeDetails();
             MailMessage mM         = new MailMessage();
             mM.From = new MailAddress(dtUserMail.Rows[0]["EmailID"].ToString());
             string[] MailTo = txtMailTo.Text.Split(';');
             foreach (string Mailid in MailTo)
             {
                 mM.To.Add(new MailAddress(Mailid));
             }
             mM.To.Add(dtUserMail.Rows[0]["EmailID"].ToString());
             mM.Subject = txtTitle.Text.Trim() + "-" + spIndex.InnerHtml;
             // string file = Server.MapPath("~/Files/") + hdfFile.Value;
             // mM.Attachments.Add(new System.Net.Mail.Attachment(file));
             mM.Body       = txtDescription.Text.Trim();
             mM.IsBodyHtml = true;
             mM.Body       = mM.Body.ToString().Replace("\n", "<br />");
             SmtpClient sC = new SmtpClient("192.9.200.214", 25);
             mM.Body += "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />This mail has been triggered to draw your attention on the respective ERP/Joomla module. Please login to respective module to see further details and file attachments";
             //   sC.Host = "192.9.200.214"; //"smtp-mail.outlook.com"// smtp.gmail.com
             //   sC.Port = 25; //587
             sC.DeliveryMethod        = SmtpDeliveryMethod.Network;
             sC.UseDefaultCredentials = false;
             sC.Credentials           = new NetworkCredential("*****@*****.**", "isgec");
             //sC.Credentials = new NetworkCredential("adskvaultadmin", "isgec@123");
             sC.EnableSsl = false;  // true
             sC.Timeout   = 10000000;
             sC.Send(mM);
             //  ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Mail has been sent');", true);
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please provide proper mail id and Content');", true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Some technical issue Mail not sent');", true);
     }
 }
Ejemplo n.º 2
0
 protected void btnSendMail_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtTo.Text != "")
         {
             objNotes      = new NotesClass();
             objNotes.User = Request.QueryString["AttachedBy"];
             DataTable   dtUserMail = objNotes.GetEmployeeDetails();
             MailMessage mM         = new MailMessage();
             mM.From = new MailAddress("*****@*****.**");
             // mM.To.Add(txtTo.Text.Trim());
             string[] MailTo = txtTo.Text.Split(';');
             foreach (string Mailid in MailTo)
             {
                 mM.To.Add(new MailAddress(Mailid));
             }
             mM.To.Add(dtUserMail.Rows[0]["EmailID"].ToString());
             mM.Subject = hdfFile.Value;
             string file = Server.MapPath("~/Files/") + hdfFile.Value;
             mM.Attachments.Add(new System.Net.Mail.Attachment(file));
             mM.Body       = hdfFile.Value;
             mM.IsBodyHtml = true;
             SmtpClient sC = new SmtpClient("192.9.200.214", 25);
             //   sC.Host = "192.9.200.214"; //"smtp-mail.outlook.com"// smtp.gmail.com
             //   sC.Port = 25; //587
             sC.DeliveryMethod        = SmtpDeliveryMethod.Network;
             sC.UseDefaultCredentials = false;
             sC.Credentials           = new NetworkCredential("*****@*****.**", "isgec");
             //sC.Credentials = new NetworkCredential("adskvaultadmin", "isgec@123");
             sC.EnableSsl = false;  // true
             sC.Timeout   = 10000000;
             sC.Send(mM);
             ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Mail has been sent');", true);
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Please provide proper mail id');", true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Some technical issue Mail not sent');", true);
     }
 }