コード例 #1
0
        public int check()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;


                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(txtEmail.Text, txtRecipientEmail.Text);
                //Create random password


                strCompanyName = Convert.ToString(ViewState["CompanyName"]);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strUserAccFundParentEmailFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.

                string strParentNm = txtFName.Text + " " + txtLName.Text;
                emailVariable["$parentName$"]     = strParentNm;
                emailVariable["$webSiteLongUrl$"] = Convert.ToString(ViewState["WebSiteLongUrl"]);
                emailVariable["$companyName$"]    = strCompanyName;

                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = strParentNm + " " + AppConstants.strAccountFundParentMailSubject + " " + strCompanyName + AppConstants.strAccountFundParentMailSubject1;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }

            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }
            return(status);
        }
コード例 #2
0
        // Function for send text email to all users.
        public int sendTextNewsletterMail()
        {
            getInfoEmailAddress();
            getAllUsersEmailAddress();

            string strToEmail   = allUsersEmailAddress;
            string strFromEmail = infoEmailAddress;

            string[] strAllUserEmails    = allUsersEmailAddress.Split(',');
            string[] strAllUserFirstName = allUsersName.Split(',');

            string strSubject = txtSubject.Text;

            try
            {
                string strEmailContent = string.Empty;
                if (strAllUserEmails.Length - 1 > 0)
                {
                    for (int email = 0; email < strAllUserEmails.Length - 1; email++)
                    {
                        MailMessage emailFromAdmin = new MailMessage(strFromEmail, strAllUserEmails[email]);

                        //Fetch file name from AppConstants class file
                        string strFileName = AppConstants.strNewsletterTextFile;

                        //object created for NameValueCollection
                        NameValueCollection emailVariable = new NameValueCollection();

                        emailVariable["$NewsLetterText$"]   = FCKeditor1.Value;
                        emailVariable["$name$"]             = strAllUserFirstName[email];
                        emailVariable["$MessageText$"]      = FCKeditor1.Value;
                        emailVariable["$InfoEmailAddress$"] = strFromEmail;
                        emailVariable["$companyName$"]      = Convert.ToString(ViewState["CompanyName"]);

                        //object created for EmailGenerator class file
                        EmailGenerator getEmailContent = new EmailGenerator();
                        strEmailContent = getEmailContent.SendEmailFromFile(strFileName, emailVariable);


                        emailFromAdmin.Subject = strSubject;
                        emailFromAdmin.Body    = strEmailContent;

                        emailFromAdmin.IsBodyHtml = true;

                        SmtpClient smtpServer = new SmtpClient();
                        smtpServer.Send(emailFromAdmin);
                    }
                    return(1);
                }
                else
                {
                    return(2);
                }
            }
            catch
            {
                return(0);
            }
        }
コード例 #3
0
        public int check(string name, string email)
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;


                DataTable dtCheckUser = new DataTable();

                MailMessage emailToUser = new MailMessage(Convert.ToString(ViewState["InfoEmail"]), email);
                //Create random password


                strCompanyName = Convert.ToString(ViewState["CompanyShortName"]);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strUserReferAFriendFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strMessage = string.Empty;
                if (txtPerMsg.Text != "")
                {
                    strMessage = txtYourName.Text + " also asked us to send this personal message:" + "<br/>" + txtPerMsg.Text;
                }
                emailVariable["$Friendname$"]  = name;
                emailVariable["$Username$"]    = txtYourName.Text;
                emailVariable["$Message$"]     = strMessage;
                emailVariable["$companyName$"] = strCompanyName;
                emailVariable["$WebsitName$"]  = Convert.ToString(ViewState["ShortURL"]);
                emailVariable["$DeliveryFee$"] = Convert.ToString(ViewState["DeliveryFee"]);
                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = AppConstants.strRefferalMailSubject + " " + strCompanyName + " " + AppConstants.strRefferalMailSubject1;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #4
0
        public int sendMail()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;

                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(Convert.ToString(ViewState["CustomerServiceEmail"]), txtEmail.Text);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strRegistrationFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strName = txtFName.Text + " " + txtLName.Text;
                emailVariable["$Username$"]          = strName;
                emailVariable["$companyName$"]       = Convert.ToString(ViewState["CompanyName"]);
                emailVariable["$DeliveryFee$"]       = Convert.ToString(ViewState["DeliveryFee"]);
                emailVariable["$DeliveryFeeCutOff$"] = Convert.ToString(ViewState["DeliveryFeeCutOff"]);
                emailVariable["$emailId$"]           = txtEmail.Text;
                emailVariable["$password$"]          = txtPassword.Text;

                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];

                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = Convert.ToString(ViewState["CompanyName"]) + " " + AppConstants.strRegistrationMailSubject;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;
                string strCC1 = "*****@*****.**";

                MailAddress cc1 = new MailAddress(strCC1);
                emailToUser.CC.Add(cc1);

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }

            return(status);
        }
コード例 #5
0
        public int check()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;


                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(txtEmail.Text, Convert.ToString(ViewState["ContactEmail"]));
                //Create random password


                strCompanyName = Convert.ToString(ViewState["CompanyShortName"]);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strUserContactEmailFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.


                emailVariable["$Name$"]        = txtName.Text;
                emailVariable["$emailId$"]     = txtEmail.Text;
                emailVariable["$Comments$"]    = txtQuestion.Text;
                emailVariable["$companyName$"] = strCompanyName;

                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = strCompanyName + " " + AppConstants.strContactUsMailSubject;


                RestClient client = new RestClient();
                client.BaseUrl       = new Uri("https://api.mailgun.net/v3");
                client.Authenticator =
                    new HttpBasicAuthenticator("api",
                                               "e5efdd7db6b16e82f92d48443ad2b87c-09001d55-530d5a9a");
                RestRequest request = new RestRequest();
                request.AddParameter("domain", "mg.cybervaletgrocery.com", ParameterType.UrlSegment);
                request.Resource = "{domain}/messages";
                request.AddParameter("from", "<*****@*****.**>");
                //Test credential//


                //Live Credential



                request.AddParameter("to", "" + Convert.ToString(ViewState["ContactEmail"]) + ";" + txtEmail.Text + "");

                request.AddParameter("subject", strsubject);


                request.AddParameter("html",
                                     "<html>" + strEmailContent + "</html>");
                // request.AddFile("attachment", Path.Combine("files", "test.jpg"));
                //  request.AddFile("attachment", Path.Combine(fileName, fileName1));
                request.Method = Method.POST;


                var reuslt = client.Execute(request);

                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #6
0
        public int check_OLD()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;


                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(txtEmail.Text, Convert.ToString(ViewState["ContactEmail"]));
                //Create random password


                strCompanyName = Convert.ToString(ViewState["CompanyShortName"]);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strUserContactEmailFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.


                emailVariable["$Name$"]        = txtName.Text;
                emailVariable["$emailId$"]     = txtEmail.Text;
                emailVariable["$Comments$"]    = txtQuestion.Text;
                emailVariable["$companyName$"] = strCompanyName;

                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = strCompanyName + " " + AppConstants.strContactUsMailSubject;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #7
0
        public int sendMailToParents()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;

                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(Convert.ToString(ViewState["ContactEmail"]), Convert.ToString(ViewState["strParentEmail"]));
                //Create random password


                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strAccFundUserParentFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strUserName = ViewState["strUserNM"] + " " + ViewState["strUserLastNM"];
                emailVariable["$UserName$"]    = strUserName;
                emailVariable["$companyName$"] = Convert.ToString(ViewState["CompanyName"]);
                emailVariable["$UserFirstNM$"] = Convert.ToString(ViewState["strUserNM"]);
                emailVariable["$UserEmail$"]   = Convert.ToString(ViewState["strUserEmail"]);


                emailVariable["$TransactionDate$"]   = Convert.ToString(ViewState["dateToday"]);
                emailVariable["$TransactionAmount$"] = Convert.ToString(txtDepositAmt.Text);



                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = AppConstants.strAccountFundUserParentMailSubject;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #8
0
        public int sendMailToUser(string depAmt, string strParentName, string Msg, string userNm, string userEmail)
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;

                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(Convert.ToString(lblContactEmail.Text), Convert.ToString(userEmail));
                //Create random password


                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strAccFundUserFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.

                emailVariable["$UserName$"]    = Convert.ToString(userNm);
                emailVariable["$companyName$"] = Convert.ToString(lblCmpNm.Text);
                emailVariable["$parentName$"]  = strParentName;
                emailVariable["$WebSiteURl$"]  = Convert.ToString(lblWeb.Text);
                emailVariable["$DepositAmt$"]  = Convert.ToString(depAmt);
                if (Msg != "NoMsg")
                {
                    emailVariable["$Message$"] = "PERSONAL MESSAGE: " + Convert.ToString(Msg);
                }
                else
                {
                    emailVariable["$Message$"] = "";
                }


                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = AppConstants.strAccountFundUserMailSubject + " " + Convert.ToString(lblCmpNm.Text) + " " + AppConstants.strAccountFundUserMailSubject1;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #9
0
        public int check()
        {
            int status = 0;

            try
            {
                string strEmailContent = string.Empty;
                string strPwd          = string.Empty;
                string strCompanyName  = string.Empty;


                DataTable dtCheckUser = new DataTable();


                //Create random password

                // new email address added uncomment on live server.//

                //   emailToUser.CC.Add("*****@*****.**");


                strCompanyName = Convert.ToString(ViewState["CompanyNm"]);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strUserOrderConfirmFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strMessage = string.Empty;
                emailVariable["$CmpName$"]       = strCompanyName;
                emailVariable["$ordNm$"]         = lblOrderNumber.Text;
                emailVariable["$ordDate$"]       = lblOrederDate.Text;
                emailVariable["$DelivDate$"]     = lblDeliveryDateTime.Text;
                emailVariable["$PaymentMethod$"] = lblPaymentMethod.Text;
                emailVariable["$SpecialOrInfo$"] = lblSpecialOrInfo.Text;
                emailVariable["$Fname$"]         = lblFName.Text;
                emailVariable["$Lname$"]         = lblLName.Text;
                emailVariable["$Phone$"]         = lblPhone.Text;
                emailVariable["$Phone2$"]        = lblPhone2.Text;
                emailVariable["$Add1$"]          = lblAddress.Text;
                emailVariable["$Add2$"]          = lblAddress2.Text;
                emailVariable["$City$"]          = lblCity.Text;
                emailVariable["$State$"]         = lblState.Text;
                emailVariable["$Zip$"]           = lblZip.Text;

                emailVariable["$Subtotal$"] = lblSubtotal.Text;
                emailVariable["$Tax$"]      = lblTax.Text;
                emailVariable["$Soda$"]     = lblSodaDeposit.Text;
                emailVariable["$Fee$"]      = lblDeliveryFee.Text;
                emailVariable["$Tip$"]      = lblTips.Text;
                emailVariable["$Total$"]    = lblOrderTotal.Text;

                emailVariable["$RentalCompany$"] = lblRentalCompanyName.Text;

                string orderDetailsString = "<table cellpadding ='0' cellspacing ='1'   width='600px' '><tr style='font-family: Arial, Helvetica, sans-serif;font-size: 15px;font-weight:bold;color:White;background-color: #e28100;'>";
                orderDetailsString += "<td style ='padding-left :5px;'  align='left' > <strong>Quantity </strong></td>";
                orderDetailsString += "<td style ='padding-left :5px;' align='left'  ><strong>Product </strong> </td>";
                orderDetailsString += "<td style ='padding-left :5px;' align='left'  ><strong>Size </strong> </td>";
                orderDetailsString += "<td style ='padding-left :5px;' align='left' ><strong>Price($)</strong></td></tr>";
                int     orderId           = Convert.ToInt32(Request.QueryString["orderId"]);
                int     userId            = Convert.ToInt32(Request.Cookies["userId"].Value);
                DataSet dsUserProductList = new DataSet();
                dsUserProductList = dbInfo.GetUserOrderProductDetail(orderId, userId);
                if (dsUserProductList.Tables.Count > 0)
                {
                    if (dsUserProductList != null && dsUserProductList.Tables.Count > 0 && dsUserProductList.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dtrow in dsUserProductList.Tables[0].Rows)
                        {
                            string ordPice = Convert.ToString(Math.Round(Convert.ToDouble(dtrow["orderproduct_price"]), 2));
                            string Qty     = Convert.ToString(Math.Round(Convert.ToDouble(dtrow["orderproduct_quantity"]), 2));
                            orderDetailsString += "<tr><td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(Qty) + " </td>";
                            orderDetailsString += "<td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(dtrow["product_title"]) + " </td>";
                            orderDetailsString += "<td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(dtrow["product_size"]) + " </td>";
                            orderDetailsString += "<td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(ordPice) + " </td></tr><tr><td height='5px'></td></tr>";
                        }
                        orderDetailsString += "</table>";
                    }
                }


                emailVariable["$orderDetails$"] = orderDetailsString;


                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = "Confirmation for" + " " + strCompanyName + " " + " order number: " + lblOrderNumber.Text;

                string strBCC1 = Convert.ToString(ViewState["ContactEmail"]);


                string strBCC2 = Convert.ToString(ViewState["CustomerServiceEmail"]);



                RestClient client = new RestClient();
                client.BaseUrl       = new Uri("https://api.mailgun.net/v3");
                client.Authenticator =
                    new HttpBasicAuthenticator("api",
                                               "e5efdd7db6b16e82f92d48443ad2b87c-09001d55-530d5a9a");
                RestRequest request = new RestRequest();
                request.AddParameter("domain", "mg.cybervaletgrocery.com", ParameterType.UrlSegment);
                request.Resource = "{domain}/messages";
                request.AddParameter("from", "<*****@*****.**>");


                //Live Credential


                request.AddParameter("to", "" + strBCC1 + ";" + Convert.ToString(ViewState["userEmailAddress"]) + "");
                request.AddParameter("bcc", "" + strBCC2 + "");
                request.AddParameter("subject", strsubject);


                request.AddParameter("html",
                                     "<html>" + strEmailContent + "</html>");
                // request.AddFile("attachment", Path.Combine("files", "test.jpg"));
                //  request.AddFile("attachment", Path.Combine(fileName, fileName1));
                request.Method = Method.POST;

                var reuslt = client.Execute(request);

                status = 1;


                //Response.Cookies.Add(emailcount);
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #10
0
        public int check_OLD()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;


                DataTable dtCheckUser = new DataTable();

                MailMessage emailToUser = new MailMessage(Convert.ToString(ViewState["ContactEmail"]), Convert.ToString(ViewState["userEmailAddress"]));
                //Create random password

                // new email address added uncomment on live server.//

                //   emailToUser.CC.Add("*****@*****.**");


                strCompanyName = Convert.ToString(ViewState["CompanyNm"]);

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strUserOrderConfirmFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strMessage = string.Empty;
                emailVariable["$CmpName$"]       = strCompanyName;
                emailVariable["$ordNm$"]         = lblOrderNumber.Text;
                emailVariable["$ordDate$"]       = lblOrederDate.Text;
                emailVariable["$DelivDate$"]     = lblDeliveryDateTime.Text;
                emailVariable["$PaymentMethod$"] = lblPaymentMethod.Text;
                emailVariable["$SpecialOrInfo$"] = lblSpecialOrInfo.Text;
                emailVariable["$Fname$"]         = lblFName.Text;
                emailVariable["$Lname$"]         = lblLName.Text;
                emailVariable["$Phone$"]         = lblPhone.Text;
                emailVariable["$Phone2$"]        = lblPhone2.Text;
                emailVariable["$Add1$"]          = lblAddress.Text;
                emailVariable["$Add2$"]          = lblAddress2.Text;
                emailVariable["$City$"]          = lblCity.Text;
                emailVariable["$State$"]         = lblState.Text;
                emailVariable["$Zip$"]           = lblZip.Text;

                emailVariable["$Subtotal$"] = lblSubtotal.Text;
                emailVariable["$Tax$"]      = lblTax.Text;
                emailVariable["$Soda$"]     = lblSodaDeposit.Text;
                emailVariable["$Fee$"]      = lblDeliveryFee.Text;
                emailVariable["$Tip$"]      = lblTips.Text;
                emailVariable["$Total$"]    = lblOrderTotal.Text;

                emailVariable["$RentalCompany$"] = lblRentalCompanyName.Text;

                string orderDetailsString = "<table cellpadding ='0' cellspacing ='1'   width='600px' '><tr style='font-family: Arial, Helvetica, sans-serif;font-size: 15px;font-weight:bold;color:White;background-color: #e28100;'>";
                orderDetailsString += "<td style ='padding-left :5px;'  align='left' > <strong>Quantity </strong></td>";
                orderDetailsString += "<td style ='padding-left :5px;' align='left'  ><strong>Product </strong> </td>";
                orderDetailsString += "<td style ='padding-left :5px;' align='left'  ><strong>Size </strong> </td>";
                orderDetailsString += "<td style ='padding-left :5px;' align='left' ><strong>Price($)</strong></td></tr>";
                int     orderId           = Convert.ToInt32(Request.QueryString["orderId"]);
                int     userId            = Convert.ToInt32(Request.Cookies["userId"].Value);
                DataSet dsUserProductList = new DataSet();
                dsUserProductList = dbInfo.GetUserOrderProductDetail(orderId, userId);
                if (dsUserProductList.Tables.Count > 0)
                {
                    if (dsUserProductList != null && dsUserProductList.Tables.Count > 0 && dsUserProductList.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dtrow in dsUserProductList.Tables[0].Rows)
                        {
                            string ordPice = Convert.ToString(Math.Round(Convert.ToDouble(dtrow["orderproduct_price"]), 2));
                            string Qty     = Convert.ToString(Math.Round(Convert.ToDouble(dtrow["orderproduct_quantity"]), 2));
                            orderDetailsString += "<tr><td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(Qty) + " </td>";
                            orderDetailsString += "<td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(dtrow["product_title"]) + " </td>";
                            orderDetailsString += "<td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(dtrow["product_size"]) + " </td>";
                            orderDetailsString += "<td align='left' bgcolor='White' class='formTextSmallPrintUser' style ='padding-left :5px;'>" + Convert.ToString(ordPice) + " </td></tr><tr><td height='5px'></td></tr>";
                        }
                        orderDetailsString += "</table>";
                    }
                }


                emailVariable["$orderDetails$"] = orderDetailsString;


                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = "Confirmation for" + " " + strCompanyName + " " + " order number: " + lblOrderNumber.Text;
                emailToUser.Subject    = strsubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;
                string strBCC1 = Convert.ToString(ViewState["ContactEmail"]);


                string strBCC2 = Convert.ToString(ViewState["CustomerServiceEmail"]);



                //if (strBCC1.Trim().Equals(strBCC2.Trim()))
                //{
                //    MailAddress bcc1 = new MailAddress(strBCC1);
                //    emailToUser.Bcc.Add(bcc1);

                //}
                //else
                //{
                //    MailAddress bcc1 = new MailAddress(strBCC1);
                //    MailAddress bcc2 = new MailAddress(strBCC2);
                //    emailToUser.Bcc.Add(bcc1);
                //    emailToUser.Bcc.Add(bcc2);
                //}
                MailAddress bcc1 = new MailAddress(strBCC1);
                MailAddress bcc2 = new MailAddress(strBCC2);


                emailToUser.Bcc.Add(bcc1);
                emailToUser.Bcc.Add(bcc2);

                SmtpClient smtpServer = new SmtpClient();
                smtpServer.Send(emailToUser);
                status = 1;
                //HttpCookie emailcount = new HttpCookie("emailcount", lblOrderNumber.Text);

                //  Response.Cookies.Add(emailcount);
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #11
0
        public int check()
        {
            int status = 0;

            try
            {
                SmtpClient smtp                      = new SmtpClient();
                string     strEmailContent           = string.Empty;
                string     strPwd                    = string.Empty;
                string     strCompanyName            = string.Empty;
                DataSet    dsSelectConstantVariables = null;

                DataTable   dtCheckUser = new DataTable();
                MailMessage emailToUser = new MailMessage(AppConstants.strAdminEmailAddress, txtAdminEmail.Text);
                //Create random password

                strPwd = GetRandomPasswordUsingGUID(7);
                ViewState["Password"]     = strPwd;
                dsSelectConstantVariables = dbloginInfo.GetConstantVaraibleInfo();
                //  dtCheckUser = dsSelectAdminForgotpass.Tables[0];
                // strCompanyName =Convert.ToString(dsSelectConstantVariables.Tables[0].Rows[0]["CompanyName"]);
                strCompanyName = "Custom Grocery";

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strForgotPasswordFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string emailText = txtAdminEmail.Text;
                emailVariable["$emailId$"]     = emailText;
                emailVariable["$password$"]    = strPwd;
                emailVariable["$companyName$"] = strCompanyName;

                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }


                emailToUser.Subject    = AppConstants.strMailSubject;
                emailToUser.Body       = strEmailContent;
                emailToUser.IsBodyHtml = true;

                SmtpClient smtpServer = new SmtpClient();

                smtpServer.Send(emailToUser);
                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }
コード例 #12
0
        public int sendMail()
        {
            int status = 0;

            try
            {
                SmtpClient smtp            = new SmtpClient();
                string     strEmailContent = string.Empty;
                string     strPwd          = string.Empty;
                string     strCompanyName  = string.Empty;

                DataTable dtCheckUser = new DataTable();



                // new email address added uncomment on live server.//



                //Create random password

                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strRegistrationFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strName = txtFName.Text + " " + txtLName.Text;
                emailVariable["$Username$"]          = strName;
                emailVariable["$companyName$"]       = Convert.ToString(ViewState["CompanyName"]);
                emailVariable["$DeliveryFee$"]       = Convert.ToString(ViewState["DeliveryFee"]);
                emailVariable["$DeliveryFeeCutOff$"] = Convert.ToString(ViewState["DeliveryFeeCutOff"]);
                emailVariable["$emailId$"]           = txtEmail.Text;
                emailVariable["$password$"]          = txtPassword.Text;
                emailVariable["$accvalue$"]          = Convert.ToString(ViewState["FirstOrderGift"]);

                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];

                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = Convert.ToString(ViewState["CompanyName"]) + " " + AppConstants.strRegistrationMailSubject;

                RestClient client = new RestClient();
                client.BaseUrl       = new Uri("https://api.mailgun.net/v3");
                client.Authenticator =
                    new HttpBasicAuthenticator("api",
                                               "e5efdd7db6b16e82f92d48443ad2b87c-09001d55-530d5a9a");
                RestRequest request = new RestRequest();
                request.AddParameter("domain", "mg.cybervaletgrocery.com", ParameterType.UrlSegment);
                request.Resource = "{domain}/messages";
                request.AddParameter("from", "<*****@*****.**>");
                //Test credential//


                //Live Credential



                request.AddParameter("to", "" + Convert.ToString(ViewState["CustomerServiceEmail"]) + ";" + txtEmail.Text + "");
                request.AddParameter("cc", "*****@*****.**");

                request.AddParameter("bcc", "" + Convert.ToString(ViewState["CustomerServiceEmail"]) + "");
                request.AddParameter("subject", strsubject);


                request.AddParameter("html",
                                     "<html>" + strEmailContent + "</html>");
                // request.AddFile("attachment", Path.Combine("files", "test.jpg"));
                //  request.AddFile("attachment", Path.Combine(fileName, fileName1));
                request.Method = Method.POST;


                var reuslt = client.Execute(request);


                status = 1;
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }
            return(status);
        }
コード例 #13
0
        public int sendMailToUser()
        {
            int status = 0;

            try
            {
                string strEmailContent = string.Empty;
                string strPwd          = string.Empty;
                string strCompanyName  = string.Empty;

                DataTable dtCheckUser = new DataTable();

                //Create random password


                //Fetch file name from AppConstants class file
                string strAdminEmailFileName = AppConstants.strAccFundUserFileName;

                //object created for NameValueCollection
                NameValueCollection emailVariable = new NameValueCollection();

                //Store values in NameValueCollection from database, for now it is fetch from datatable
                //which is hardcoded.
                string strParentName = txtFName.Text + " " + txtLName.Text;
                emailVariable["$UserName$"]    = Convert.ToString(ViewState["strUserNM"]);
                emailVariable["$companyName$"] = Convert.ToString(ViewState["CompanyName"]);
                emailVariable["$parentName$"]  = strParentName;
                emailVariable["$WebSiteURl$"]  = Convert.ToString(ViewState["WebSiteURl"]);
                emailVariable["$DepositAmt$"]  = Convert.ToString(txtDepositAmt.Text);
                if (txtPerMsg.Text != "")
                {
                    emailVariable["$Message$"] = "PERSONAL MESSAGE: " + Convert.ToString(txtPerMsg.Text);
                }
                else
                {
                    emailVariable["$Message$"] = "";
                }


                //object created for EmailGenerator class file

                EmailGenerator getEmailContent = new EmailGenerator();
                string         strChkEmailFromDatabaseorFile = string.Empty;
                strChkEmailFromDatabaseorFile = ConfigurationSettings.AppSettings["mailtoread"];
                if (strChkEmailFromDatabaseorFile == "fromtextfile")
                {
                    strEmailContent = getEmailContent.SendEmailFromFile(strAdminEmailFileName, emailVariable);
                }

                string strsubject = AppConstants.strAccountFundUserMailSubject + " " + Convert.ToString(ViewState["CompanyName"]) + " " + AppConstants.strAccountFundUserMailSubject1;


                RestClient client = new RestClient();
                client.BaseUrl       = new Uri("https://api.mailgun.net/v3");
                client.Authenticator =
                    new HttpBasicAuthenticator("api",
                                               "e5efdd7db6b16e82f92d48443ad2b87c-09001d55-530d5a9a");
                RestRequest request = new RestRequest();
                request.AddParameter("domain", "mg.cybervaletgrocery.com", ParameterType.UrlSegment);
                request.Resource = "{domain}/messages";
                request.AddParameter("from", "<*****@*****.**>");

                request.AddParameter("to", "" + Convert.ToString(ViewState["ContactEmail"]) + ";" + Convert.ToString(ViewState["strUserEmail"]) + "");

                request.AddParameter("subject", strsubject);


                request.AddParameter("html",
                                     "<html>" + strEmailContent + "</html>");
                // request.AddFile("attachment", Path.Combine("files", "test.jpg"));
                //  request.AddFile("attachment", Path.Combine(fileName, fileName1));
                request.Method = Method.POST;

                var reuslt = client.Execute(request);
                status = 1;
            }

            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            return(status);
        }