internal static void Seed(BillsPaymentSystemContext context, int count)
        {
            for (int i = 0; i < count; i++)
            {
                var firstName = TextGenerator.FirstName();
                var user      = new User()
                {
                    FirstName = firstName,
                    LastName  = TextGenerator.LastName(),
                    Email     = EmailGenerator.NewEmail(firstName),
                    Password  = TextGenerator.Password(12)
                };

                var result = new List <ValidationResult>();
                if (AttributeValidator.IsValid(user, result))
                {
                    context.Users.Add(user);
                }
                else
                {
                    Console.WriteLine(string.Join(Environment.NewLine, result));
                }
            }

            context.SaveChanges();
        }
Example #2
0
        public void EmailGenerator_GenerateEmail_SUCCESS()
        {
            string generated = EmailGenerator.GenerateEmailAddress();

            Assert.NotNull(generated);
            Assert.NotEmpty(generated);
        }
        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);
        }
Example #4
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);
            }
        }
Example #5
0
        //[ApiAuthFilter]
        public IHttpActionResult SendInvoiceMail(string BookingNo, string EmailId)
        {
            try
            {
                TripInvoice tripInvoiceList = new CustomerBO().GetTripInvoiceList(new TripInvoice
                {
                    BookingNo = BookingNo
                });

                DriverTripInvoice driverTripInvoice = new DriverBO().GetDriverTripInvoice(new DriverTripInvoice
                {
                    BookingNo = BookingNo
                });
                CompanyTripInvoice companyTripInvoice = new CustomerBO().GetCompanyTripInvoiceList(new CompanyTripInvoice
                {
                    BookingNo = BookingNo
                });

                InvoiceDTO invoiceDTO = new InvoiceDTO();
                invoiceDTO.CompanyTripInvoice = companyTripInvoice;
                invoiceDTO.DriverTripInvoice  = driverTripInvoice;
                invoiceDTO.TripInvoice        = tripInvoiceList;

                byte[] pdf; // result will be here

                var cssText = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Areas/Master/Views/Driver/bootstrap.css"));
                var html    = this.RenderView <InvoiceDTO>("~/Areas/Master/Views/Driver/Invoices.cshtml", invoiceDTO);
                using (var memoryStream = new MemoryStream())
                {
                    var document = new Document(PageSize.A4, 25f, 25f, 25f, 25f);
                    var writer   = PdfWriter.GetInstance(document, memoryStream);
                    document.Open();

                    using (var cssMemoryStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(cssText)))
                    {
                        using (var htmlMemoryStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)))
                        {
                            XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, htmlMemoryStream, cssMemoryStream);
                        }
                    }
                    document.Close();
                    pdf = memoryStream.ToArray();
                    bool sendCustomerMail = new EmailGenerator().ConfigMail(EmailId, true, "PickC Invoice", "<div>PickC Invoice</div>", pdf);
                    if (sendCustomerMail)
                    {
                        return(Ok("Invoice Is Sent To Your Mail!"));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
Example #6
0
        public void EmailGenerator_GenerateEmailAddressWithWords_SUCCESS()
        {
            int    numberOfWords = 3;
            string wordSeparator = ".";

            string generated = EmailGenerator.GenerateEmailAddressWithWords(numberOfWords, wordSeparator);

            Assert.NotNull(generated);
            Assert.NotEmpty(generated);
        }
Example #7
0
        public void GivenIHaveEnteredDefaultValuesInTheFieldsAndSpecificWithFirstNameAndSecondNameValues(string firstName, string secondName)
        {
            string randomEmail = EmailGenerator.GenerateRandomEmail();

            ScenarioContext.Current.Get <LoginSignupPage>().
            SetFirstName(firstName).
            SetLastName(secondName).
            SetMobileOrEmail(randomEmail).
            ReenterMobileOrEmail(randomEmail).
            SetNewPassword("paSS3@").
            SetGender(LoginSignupPage.Gender.Female);
        }
Example #8
0
        public void GivenIHaveEnteredDefaultValuesInTheFieldsAndSpecificWithPassword(string password)
        {
            string randomEmail = EmailGenerator.GenerateRandomEmail();

            ScenarioContext.Current.Get <LoginSignupPage>().
            SetFirstName("John").
            SetLastName("Corezina").
            SetMobileOrEmail(randomEmail).
            ReenterMobileOrEmail(randomEmail).
            SetNewPassword(password).
            SetGender(LoginSignupPage.Gender.Female);
        }
Example #9
0
        public async Task <bool> WarningDrugsEmail(string id)
        {
            if (id == null)
            {
                return(false);
            }
            var drug = await dataContext.Drugs.SingleOrDefaultAsync(x => x.Id == id);

            var sendAdminBody = EmailGenerator.GenerateWarningDrugsEmailTemplate(drug.Id, drug.Name);
            await emailSender.SendEmailAsync(sendAdminBody, "Drug About to Finish !!!", "*****@*****.**");

            return(true);
        }
Example #10
0
        public async Task <bool> RegistrationSuccessEmail(string id)
        {
            if (id != null)
            {
                var user = await dataContext.Users.SingleOrDefaultAsync(x => x.Id == id);

                var sendUserBody = EmailGenerator.GenerateRegistrationSuccessEmailTemplate(user.FirstName, user.LastName);
                await emailSender.SendEmailAsync(sendUserBody, "Registration Successful", user.EmailAddress);

                return(true);
            }

            return(false);
        }
Example #11
0
        public async Task <bool> UpdateAppointmentEmail(string id)
        {
            if (id == null)
            {
                return(false);
            }

            var currentAppointment = await dataContext.Appointments.Include(x => x.User).SingleOrDefaultAsync(x => x.Id == id);

            var user         = currentAppointment.User;
            var sendUserBody = EmailGenerator.GenerateUpdateAppointmentUserEmailTemplate(user.FirstName, user.LastName, currentAppointment.Id);
            await emailSender.SendEmailAsync(sendUserBody, "Updated Scheduled Appointment", user.EmailAddress);

            return(true);
        }
        public async Task <IActionResult> ChangePassword([FromBody] UserDto userDto,
                                                         CancellationToken cancellationToken = default)
        {
            var success = await userService.ChangePassword(userDto, cancellationToken);

            if (!success)
            {
                return(UnprocessableEntity("Failed to change password"));
            }

            await emailService.SendEmail(EmailGenerator
                                         .PasswordChangeMessage(userDto.Email), cancellationToken);

            return(NoContent());
        }
        private static StudentDto GetStudent()
        {
            var name = TextGenerator.FirstName;

            return(new StudentDto()
            {
                Name = name,
                Gender = "Male",
                BirthDate = DateGenerator.PastDate.ToString("yyyy'/'MM'/'dd"),
                PhoneNumber = IntGenerator.GenerateInt(1000000, 9999999),
                Email = EmailGenerator.NewEmail(name),
                FacultyNumber = IntGenerator.GenerateInt(1000000, 9999999),
                Specialty = TextGenerator.Text("C# Web Developer", "Java Web Developer", "JavaScript FrontEnd Developer"),
                University = "SoftUni",
                Exams = GetExams(1)
            });
        }
Example #14
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var config = _serviceConfig.Value;
            var server = new Server
            {
                Services = { EmailGenerator.BindService(_service) },
                Ports    = { new ServerPort(config.Host, config.Port, ServerCredentials.Insecure) }
            };

            server.Start();

            _logger.LogInformation("Email Generator is running on {Host}:{Port}.", config.Host, config.Port);
            await stoppingToken;

            _logger.LogWarning("Cancellation received. Shutting down Email Generator.");
            await server.ShutdownAsync();
        }
Example #15
0
        public async Task <IActionResult> ForgottenPassword(ForgottenPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await _identityService.GetPasswordResetResult(model.Email);

                if (result.IsSucessfull)
                {
                    var          link    = Url.Action("ResetPassword", "Account", result.Values[0], Request.Scheme);
                    EmailMessage message = EmailGenerator.GeneratePasswordResetMessage(link, model.Email);
                    await _emailService.SendEmailAsync(message);
                }

                return(View("ForgotPasswordConfirmation"));
            }

            return(View());
        }
Example #16
0
        public async Task <bool> AddAppointmentEmail(Appointment appointment)
        {
            if (appointment == null)
            {
                return(false);
            }

            var user = appointment.User;

            var sendUserBody  = EmailGenerator.GenerateAddAppointmentUserEmailTemplate(appointment.Id);
            var sendAdminBody = EmailGenerator.GenerateAddAppointmentEmailTemplate(appointment.Id, appointment.DateofAppointment.ToString(), appointment.PurposeofAppointment, appointment.DateAppointmentMade.ToString(), user.FirstName, user.LastName);

            await emailSender.SendEmailAsync(sendUserBody, "Appointment Added", user.EmailAddress);

            await emailSender.SendEmailAsync(sendAdminBody, "User Added Appointment", "*****@*****.**");

            return(true);
        }
Example #17
0
        public async Task <TaskResult> SendForTaskResult(TaskResult result, MessageData data)
        {
            if (!result.Success)
            {
                return(result);
            }

            var url     = data.GetEndpointUrl(emailConfiguration.UrlBase);
            var message = EmailGenerator.GenerateMessage(data.Recipient, data.Type, url);

            try
            {
                await SendEmail(message);

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(new TaskResult(new[] { "Failed to send email" }));
            }
        }
Example #18
0
        //[ApiAuthFilter]

        public IHttpActionResult SendMessageToPickC(ContactUs contactUs)
        {
            try
            {
                contactUs.CreatedBy = UTILITY.DEFAULTUSER;
                bool   result   = new CustomerBO().SaveCustomer(contactUs);
                string fromMail = string.Empty;
                if (result == true)
                {
                    if (contactUs.Type == "CustomerSupport" || contactUs.Type == "FeedBack")
                    {
                        fromMail = "*****@*****.**";
                    }
                    else if (contactUs.Type == "ContactUs" || contactUs.Type == "Careers")
                    {
                        fromMail = "*****@*****.**";
                    }
                    bool sendMail = new EmailGenerator().ConfigMail(fromMail, true, contactUs.Subject, contactUs.Message);

                    if (sendMail)
                    {
                        return(Ok("Mail Sent Successfully!"));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception exception)
            {
                return(InternalServerError(exception));
            }
        }
        public async Task <IActionResult> Register([FromBody] UserDto userDto,
                                                   CancellationToken cancellationToken = default)
        {
            var success = await userService.CreateUser(userDto, cancellationToken);

            if (!success)
            {
                return(UnprocessableEntity("User cannot be created"));
            }

            try
            {
                await emailService.SendEmail(EmailGenerator
                                             .RegistrationMessage(userDto.Email), cancellationToken);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            var token = userService.GenerateJwt(userDto);

            return(Ok(new { token }));
        }
Example #20
0
 private IGenerator GetEmailGenerator()
 {
     return(_emailGenerator ?? (_emailGenerator = new EmailGenerator()));
 }
        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);
        }
        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);
        }
        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);
        }
 public EmailGeneratorTest()
 {
     _emailGenerator = new EmailGenerator();
 }
Example #25
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);
        }
Example #26
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);
        }
        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);
        }
Example #28
0
 public void GivenICreateANewUserEmailAddress()
 {
     _email = EmailGenerator.GenerateEmailAddress();
     _tokenManager.SetToken(BindingData.UserEmailAddressTokenName, _email);
     _tokenManager.SetToken(BindingData.InvalidPasswordTokenName, new string(BindingData.Password.Reverse().ToArray()));
 }
        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);
        }
        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);
        }