Exemple #1
0
    //User Right Function===========
    #endregion

    public void SendMail(int reqid)
    {
        try
        {
            DataSet dslogin = new DataSet();
            Ds = new DataSet();
            DMRequisitionCafeteria Obj_RequisitionCafeteria = new DMRequisitionCafeteria();
            Ds = Obj_RequisitionCafeteria.GETDATAFORMAIL(reqid, out StrError);
            if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
            {
                //-------------------------------------------------[Mail Code]-------------------------------------------------
                string smtpServer = "smtp.gmail.com";
                string userName   = "******";
                string password   = "******";


                //string smtpServer = "smtp.mail.yahoo.com";//localhost
                //string userName = "******";//[email protected]
                //string password = "******";//saprapune@12345

                int         cdoBasic         = 1;
                int         cdoSendUsingPort = 2;
                MailMessage msg = new MailMessage();
                if (userName.Length > 0)
                {
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
                    msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", true);
                }

                msg.To = "*****@*****.**";
                //  msg.To="*****@*****.**";
                //if (txtCC.Text != "")
                //{
                //    msg.Cc = txtCC.Text;
                //}
                //if (txtBcc.Text != "")
                //{
                //    msg.Bcc = txtBcc.Text;
                //}

                msg.From = "*****@*****.**";
                // msg.From = "*****@*****.**";
                msg.Subject = "Material Request From " + Ds.Tables[0].Rows[0]["Employee"].ToString().ToUpper() + " (" + Ds.Tables[0].Rows[0]["Site"].ToString() + " )-( REQ. NO. : " + Ds.Tables[0].Rows[0]["RequisitionNo"].ToString() + " ) Has Been Approved";
                string mystring = "Hello Sir,<br/> Request No. : " + Ds.Tables[0].Rows[0]["RequisitionNo"].ToString() + "<br/>" + "Request Date :" + Ds.Tables[0].Rows[0]["ReqDate"].ToString() + "<br/> Please Check This Request For PO";
                mystring = mystring.Replace("<br/>", System.Environment.NewLine);
                msg.Body = mystring.ToString();

                SmtpMail.SmtpServer = smtpServer;
                SmtpMail.Send(msg);
            }
            //  -------------------------------------------------[End Mail Code]-------------------------------------------------
        }
        catch (Exception)
        {
        }
    }
Exemple #2
0
    public void SendMail(int reqid)
    {
        bool        Flag = false;
        MailMessage Mail = new MailMessage();

        try
        {
            //Mail.To.Add("*****@*****.**");
            //Mail.From = new System.Net.Mail.MailAddress("*****@*****.**");
            //// Mail.From = new MailAddress("*****@*****.**");Mail.From = new MailAddress("*****@*****.**");
            //Mail.CC.Add("*****@*****.**");
            //Mail.Subject = "Warranty Registration";

            //Mail.Body = "Hello Test ";

            Ds = Obj_RequisitionCafeteria.GETDATAFORMAIL(reqid, out StrError);
            TRLOADING.Visible = true;
            string path = GETPDF(reqid);

            if (Ds.Tables.Count > 0 && Ds.Tables[0].Rows.Count > 0)
            {
                Mail.To.Add("" + TXTKTO.Text + "");
                if (!string.IsNullOrEmpty(TXTKCC.Text))
                {
                    Mail.CC.Add("" + TXTKCC.Text + ""); //= TXTKCC.Text;
                }
                Mail.Subject = TXTKSUBJECT.Text;
                Mail.Body    = TxtBody.Text;
                Mail.From    = new MailAddress("*****@*****.**"); //"*****@*****.**";
                if (CHKATTACHBROUCHER.Checked == true)
                {
                    //Mail.Attachments.Add(new System.Web.Mail.MailAttachment(sFile));
                    //Mail.Attachments.Add(Mail.Attachments());
                    Mail.Attachments.Add(new Attachment(path));
                }

                Mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient("smtp.rediffmailpro.com", 587);
                smtp.Host = "smtp.rediffmailpro.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = true;//true
                smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "mehta123");



                smtp.EnableSsl = false;//false
                smtp.Send(Mail);
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                Flag = true;
                //int EmailStatus = Obj_RequisitionCafeteria.UpdateEmailStatus(reqid, out StrError);
                MakeEmptyForm();
                TRLOADING.Visible = false;
                //return Flag;
                //  -------------------------------------------------[End Mail Code]-------------------------------------------------
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }