public static EmailManager getInstance()
 {
     if (instance == null)
     {
         instance = new EmailManager();
     }
     return instance;
 }
    protected void btnRefund_Click( object sender , EventArgs e )
    {
        PayPalManager payPal = new PayPalManager();
        payPal.RefundTransaction( Request.QueryString[ "TransId" ] );

        Orders orders = new Orders();
        ProcessUpdateOrder updateOrder = new ProcessUpdateOrder();

        int refundedstatustype = 3;

        orders.OrderId = int.Parse( Request.QueryString["OrderId"] );
        orders.OrderStatusId = refundedstatustype;
        orders.ShipDate = ( DateTime ) SqlDateTime.Null;
        updateOrder.Orders = orders;

        try
        {
            updateOrder.Invoke();

            if (payPal.IsSubmissionSuccess)
            {
                EmailManager emailMngr = new EmailManager();
                EmailContents mailContents = new EmailContents();

                mailContents.To = Request.QueryString["Email"];
                mailContents.Bcc = EmailAddressConstants.Simon;
                mailContents.Subject = "Live Free Range Update - Order ID: " + Request.QueryString["OrderID"];
                mailContents.Body = "Your order has been refunded.  Please log into your account for details.";
                mailContents.FromEmailAddress = EmailAddressConstants.Contact;

                emailMngr.Send(mailContents);

                if (!emailMngr.IsSent)
                {
                    Response.Redirect("../ErrorPage.aspx");
                }
            }
        }
        catch(Exception ex)
        {
            Response.Redirect("../ErrorPage.aspx");
        }

        Response.Redirect("Orders.aspx");
    }
Example #3
0
        public ActionResult ForgotPasword(ForgotPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                if (Metodos.ValidarEmailUsuario(model.Email))
                {
                    string _esquema  = Request.Url.Scheme;
                    string _hostName = Request.Url.Host;

                    EmailManager.EnviarEmailConfirmPassword(model.Email, this.ControllerContext, RouteTable.Routes, _esquema, _hostName);
                    return(RedirectToAction("EmailSent"));
                }
                else
                {
                    ModelState.AddModelError("Email", Resources.ErrorResource.EmailError);
                }
            }
            return(View(model));
        }
        public async void ComposeMail(string fileName, string[] recipients, string subject, string messagebody, MemoryStream documentStream)
        {
            var emailMessage = new EmailMessage
            {
                Subject = subject,
                Body    = messagebody
            };
            StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;

            StorageFile outFile = await local.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

            using (Stream outStream = await outFile.OpenStreamForWriteAsync())
            {
                outStream.Write(documentStream.ToArray(), 0, (int)documentStream.Length);
            }
            emailMessage.Attachments.Add(new EmailAttachment(fileName, outFile));

            await EmailManager.ShowComposeNewEmailAsync(emailMessage);
        }
Example #5
0
        public async Task <ActionResult> ForgetPassword(ForgetPasswordVm model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                var repo = new RepositoryBase <User>(_db);
                var user = repo.GetItemByExpression(x => x.Cpf.Equals(model.UserName), x => x.Contacts);
                if (user == null)
                {
                    return(View(model).Success("Um código para redefinição da sua senha foi enviado para o seu email"));
                }
                user.SetPasswordRecoveryCode();

                var query = $"UPDATE [{nameof(Domain.Entities.User)}] SET {nameof(user.PasswordRecoveryCode)}='{user.PasswordRecoveryCode}' WHERE {nameof(user.UserId)}='{user.UserId}'";
                await _db.Database.ExecuteSqlCommandAsync(query);

                var email = user.Contacts.FirstOrDefault(f => f.ContactType == ContactType.Email)?.Description;

                if (string.IsNullOrWhiteSpace(email))
                {
                    return(View(model).Error("Não foi possível enviar um email com o seu código de recuperação, pois não existe nenhum Email para contato"));
                }

                var emailManager = new EmailManager(new ArrayList {
                    email
                });
                var actualUrl = Request.Url.OriginalString;
                var url       = $"{actualUrl.Replace(Request.Url.Segments[Request.Url.Segments.Length - 1], "recoverypassword")}/{user.PasswordRecoveryCode}";

                emailManager.ForgotPassword(user.FullName, url);
                await emailManager.SendAsync(emailManager.Sender, $"Sistema {Constants.SystemName}");

                return(View(model).Success($"Um código para redefinição da sua senha foi enviado para o seu email: '{email}'"));
            }
            catch (Exception e)
            {
                return(View(model).Error(e.Message));
            }
        }
Example #6
0
    private void SendMessage()
    {
        if (IsValid)
        {
            EmailContents contents = new EmailContents();
            contents.FromName = this.txtName.Text;
            contents.FromEmailAddress = this.txtEmail.Text;
            contents.Body = this.txtComment.Text;
            contents.Subject = "Website Feedback";

            EmailManager emailMngr = new EmailManager();
            emailMngr.Send(contents);

            if (emailMngr.IsSent)
            {
                Response.Redirect("ContactUsConfirm.aspx");
            }
        }
    }
Example #7
0
        private async void ComposeEmail()
        {
            EmailMessage emailMessage = new EmailMessage();

            emailMessage.To.Add(new EmailRecipient("*****@*****.**"));
            string messageSubject = "Whiskly User Feedback";

            var    sysInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
            var    ai      = AnalyticsInfo.VersionInfo;
            string sv      = ai.DeviceFamilyVersion;
            ulong  v       = ulong.Parse(sv);
            ulong  v1      = (v & 0xFFFF000000000000L) >> 48;
            ulong  v2      = (v & 0x0000FFFF00000000L) >> 32;
            ulong  v3      = (v & 0x00000000FFFF0000L) >> 16;
            ulong  v4      = (v & 0x000000000000FFFFL);

            var timeNow     = DateTime.UtcNow;
            var deviceMan   = sysInfo.SystemManufacturer;
            var deviceMod   = sysInfo.SystemProductName;
            var deviceOS    = $"{v1}.{v2}.{v3} ({v4})";
            var deviceArch  = Package.Current.Id.Architecture;
            var userID      = "";
            var userLang    = Windows.Globalization.Language.CurrentInputMethodLanguageTag;
            var userCarrier = "";
            var networkStat = NetworkInformation.GetInternetConnectionProfile();

            string messageBody = "---"
                                 + "\n" + assemblyInformation
                                 + "\n" + timeNow
                                 + "\n" + "Device Manufactuer: " + deviceMan
                                 + "\n" + "Device Model: " + deviceMod
                                 + "\n" + "OS: " + deviceOS
                                 + "\n" + "Architecture: " + deviceArch
                                 + "\n" + "User ID: " + userID
                                 + "\n" + "Language: " + userLang
                                 + "\n" + "Carrier: " + userCarrier
                                 + "\n" + "Network Status: " + networkStat.ServiceProviderGuid;

            emailMessage.Subject = messageSubject;
            emailMessage.Body    = messageBody;

            await EmailManager.ShowComposeNewEmailAsync(emailMessage);
        }
Example #8
0
        public ActionResult ThankYou(int id, string referenceid)
        {
            BookingsListModel   model    = new BookingsListModel();
            List <BookingModel> bookings = new List <BookingModel>();

            bookings              = TheRepository.GetAllBookingsByCustomer(id).Where(a => a.bookingReference == referenceid).ToList();
            bookings              = bookings.Where(a => a.bookingFulfilled == false).ToList();
            model.bookings        = bookings;
            model.serviceProvider = TheRepository.GetServiceProvider(model.bookings[0].serviceProviderId);
            model.customer        = TheRepository.GetCustomer(id);

            //Send an authorisation email to the customer
            EmailInfo emailInfo = new EmailInfo();

            emailInfo.Body       = $"Welcome from I NEED YOUR TIME. Please see below for details of the appointment";
            emailInfo.emailType  = "Appointment confirmation";
            emailInfo.IsBodyHtml = true;
            emailInfo.Subject    = "Welcome to INYT";
            emailInfo.ToAddress  = model.customer.emailAddress;
            //_emailManager.SendEmail(emailInfo);
            var model2 = new Emailmodel
            {
                Name = model.customer.firstName,
                Body = emailInfo.Body
            };
            var renderedHTML = ControllerExtensions.RenderViewAsHTMLString(this, "_VerifyEmail.cshtml", model2);

            EmailManager.SendEmail2(model.customer.emailAddress, "VerifyAccount", renderedHTML.Result);

            if (bookings != null)
            {
                foreach (var booking in bookings)
                {
                    booking.bookingFulfilled = true;
                    booking.bookingAccepted  = true;
                    booking.bookingReference = referenceid;
                    TheRepository.UpdateBooking(booking);
                }
            }

            return(View(model));
        }
Example #9
0
        private void SendEmail(string toAddress, string emailCustomer, string emailBody, List <string> attachments)
        {
            string fromEmailAddress = "";

            if (getSetting <string>("EmailAddressFrom") == "0")
            {
                fromEmailAddress = Site.CurrentWorkingEnvironment.EmailSettingsFrom;
            }

            if (getSetting <string>("EmailAddressFrom") == "1")
            {
                fromEmailAddress = emailCustomer;
            }

            if (getSetting <string>("EmailAddressFrom") == "2")
            {
                fromEmailAddress = getSetting <string>("ContactFormSender");
            }
            string bcc = getSetting <string>("BCCEmailAddress");

            string toType = getSetting <string>("RecipientTypeTo");

            if (toType == null || toType == "" || toType == "static")
            {
                toAddress = getSetting <string>("ContactFormRecipient");
            }

            string debugEmailAddress = getSetting <string>("DebugEmailAddress");

            if (bcc != null && bcc != "" && Regex.Match(bcc, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
            {
                if (debugEmailAddress != null && debugEmailAddress != "")
                {
                    bcc = bcc + ";" + debugEmailAddress;
                }
                EmailManager.SendMail(fromEmailAddress, toAddress, getSetting <string>("ContactFormSubject"), emailBody, true, attachments.ToArray(), bcc);
            }
            else
            {
                EmailManager.SendMail(fromEmailAddress, toAddress, getSetting <string>("ContactFormSubject"), emailBody, true, attachments.ToArray(), debugEmailAddress);
            }
        }
Example #10
0
        public void AssignTech(AdmIssueViewModel model, int issueId)
        {
            if (model.AssignToId == null)
            {
                return;
            }

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                // first see if there is already an assignment with issue and tech, if so don't create another
                Assignment assignment = db.Assignments.FirstOrDefault(a => a.IssueId == issueId && a.UserId == model.AssignToId);
                if (assignment == null)  // did not find assignment
                {
                    // create assignment
                    assignment = new Assignment()
                    {
                        IssueId = issueId,
                        UserId  = model.AssignToId,
                    };
                    db.Assignments.Add(assignment);

                    Issue issue = db.Issues.FirstOrDefault(i => i.IssueId == issueId);
                    if (issue != null && issue.IsAssigned == false)
                    {
                        issue.IsAssigned = true;
                    }

                    string tech_name = db.Users.Find(model.AssignToId).FirstName;
                    TimeLineHelper.AssigmentOperations(issue.User.UserName, TimeLineHelper.Operations.New, issue.IssueId, tech_name);
                    string           ticketId = issue.IssueId.ToString();
                    AdmUserViewModel tech     = GetUserById(model.AssignToId);

                    string tech_email = tech.Email;
                    // email user and tell them that the issue has been updated
                    EmailManager.SendEmailAdminAssignTicket(ticketId, tech_email, issue.IssueDesc);
                }

                db.SaveChanges();
            }

            return;
        }
        /*
         * //with sendgrid api
         * public static bool SendEmail(string subject, string message, string toemail, bool IsHTML = true)
         * {
         *
         *
         *  // Your gmail email address
         *  var FromEmail = ConfigurationManager.AppSettings["MailUser"];//"*****@*****.**";
         *  var apiKey = ConfigurationManager.AppSettings["SendGridKey"];
         *
         *
         *  try
         *  {
         *      var client = new SendGridClient(apiKey);
         *      var from = new EmailAddress(FromEmail, "SILPO - Balai Penelitian Tanah");
         *
         *      var to = new EmailAddress(toemail);
         *      var plainTextContent = message;
         *      var htmlContent = IsHTML ? message : $"<strong>{message}</strong>";
         *      var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
         *      var response = client.SendEmailAsync(msg).GetAwaiter().GetResult();
         *      return response.StatusCode == HttpStatusCode.Accepted;
         *  }
         *  catch (Exception ex)
         *  {
         *      //Console.WriteLine("failed to send email with the following error:");
         *      //Console.WriteLine(ep.Message);
         *      LogHelpers.source = typeof(EmailService).ToString();
         *      LogHelpers.message = "failed to send email with the following error:" + ex.Message;
         *      LogHelpers.user = CommonWeb.GetCurrentUser();
         *      LogHelpers.WriteLog();
         *      return false;
         *  }
         * }
         */
        /*
         * //with SMTP
         * public static bool SendEmail(string subject, string message, string toemail,bool IsHTML=true)
         * {
         *  SmtpMail oMail = new SmtpMail("TryIt");
         *  SmtpClient oSmtp = new SmtpClient();
         *
         *  // Your gmail email address
         *  oMail.From = ConfigurationManager.AppSettings["MailUser"];//"*****@*****.**";
         *
         *  // Set recipient email address
         *  oMail.To = toemail;
         *
         *  // Set email subject
         *  oMail.Subject = subject;
         *
         *  // Set email body
         *  if (IsHTML)
         *      oMail.HtmlBody = message;
         *  else
         *      oMail.TextBody = message;
         *
         *  // Gmail SMTP server address
         *  SmtpServer oServer = new SmtpServer(ConfigurationManager.AppSettings["MailServer"]);//"SMTP.Office365.com"
         *
         *  // If you want to use direct SSL 465 port,
         *  // please add this line, otherwise TLS will be used.
         *  // oServer.Port = 465;
         *
         *  // set 587 TLS port;
         *  oServer.Port = int.Parse(ConfigurationManager.AppSettings["MailPort"]); //587;
         *
         *  // detect SSL/TLS automatically
         *  oServer.ConnectType = SmtpConnectType.ConnectSTARTTLS;
         *
         *  // Gmail user authentication
         *  // For example: your email is "*****@*****.**", then the user should be the same
         *  oServer.User = ConfigurationManager.AppSettings["MailUser"];//"*****@*****.**";
         *  oServer.Password = ConfigurationManager.AppSettings["MailPassword"];//"Balittanah123";
         *
         *  try
         *  {
         *      Console.WriteLine("start to send email over SSL ...");
         *      oSmtp.SendMail(oServer, oMail);
         *      Console.WriteLine("email was sent successfully!");
         *      return true;
         *  }
         *  catch (Exception ex)
         *  {
         *      //Console.WriteLine("failed to send email with the following error:");
         *      //Console.WriteLine(ep.Message);
         *      LogHelpers.source = typeof(EmailService).ToString();
         *      LogHelpers.message = "failed to send email with the following error:"+ ex.Message;
         *      LogHelpers.user = CommonWeb.GetCurrentUser();
         *      LogHelpers.WriteLog();
         *      return false;
         *  }
         * }*/
        //using outlook without EAMail
        public static bool SendEmail(string subject, string message, string toemail, bool IsHTML = true)
        {
            string smtpServer = "smtp-mail.outlook.com";

            var UserMail     = ConfigurationManager.AppSettings["MailUser"];     //"*****@*****.**";
            var UserPassword = ConfigurationManager.AppSettings["MailPassword"]; //"Balittanah123";

            try
            {
                //Send teh High priority Email
                EmailManager mailMan = new EmailManager(smtpServer);

                EmailSendConfigure myConfig = new EmailSendConfigure();
                // replace with your email userName
                myConfig.ClientCredentialUserName = UserMail;
                // replace with your email account password
                myConfig.ClientCredentialPassword = UserPassword;
                myConfig.TOs             = new string[] { toemail };
                myConfig.CCs             = new string[] { };
                myConfig.From            = UserMail;
                myConfig.FromDisplayName = "SILPO - Balai Penelitian Tanah";
                myConfig.Priority        = System.Net.Mail.MailPriority.Normal;
                myConfig.Subject         = subject;

                EmailContent myContent = new EmailContent();
                myContent.Content = message;
                myContent.IsHtml  = IsHTML;
                mailMan.SendMail(myConfig, myContent);
                Console.WriteLine("email was sent successfully!");
                return(true);
            }
            catch (Exception ex)
            {
                //Console.WriteLine("failed to send email with the following error:");
                //Console.WriteLine(ep.Message);
                LogHelpers.source  = typeof(EmailService).ToString();
                LogHelpers.message = "failed to send email with the following error:" + ex.Message;
                LogHelpers.user    = CommonWeb.GetCurrentUser();
                LogHelpers.WriteLog();
                return(false);
            }
        }
Example #12
0
        public async Task <ActionResult> ApproveUser(string id)
        {
            try
            {
                var oldUser = await _repo.FindUserById(id);

                if (oldUser != null)
                {
                    var result = await _repo.UpdatePhoneNumberConfirmed(oldUser, true);

                    if (result.Succeeded)
                    {
                        var setting =
                            _UnitOfWork
                            .EmailSetting
                            .GetEmailSetting(EmailType.ActivateAgent.GetHashCode().ToString());


                        EmailManager.SendWelcomeEmail(EmailType.ActivateAgent.GetHashCode().ToString(),
                                                      oldUser.Email,
                                                      setting.MessageBodyAr.Replace("@FullName", oldUser.FullName));

                        return(Json("OK", JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("NotFound", JsonRequestBehavior.AllowGet));
                    }
                }
                //return RedirectToAction("AgentsRequest").Error("هذا المندوب غير موجود .");

                return(Json("NotFound", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorSaver.SaveError(ex.Message);

                return(Json("Error", JsonRequestBehavior.AllowGet));

                // return RedirectToAction("AgentsRequest").Error("حدث خطأ أثناء قبول المندوب.");
            }
        }
Example #13
0
        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool isEmail = Regex.IsMatch(model.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

                    if (!isEmail)
                    {
                        ModelState.AddModelError("", "Enter valid email address.");
                        return(View(model));
                    }

                    var contact = contactService.GetByUsername(model.Email);

                    if (!contact.Success)
                    {
                        ViewBag.Error = "User does not exists!";
                        return(View(model));
                    }
                    else
                    {
                        var user_data        = new { ct_key = contact.Result.ct_key, Date = DateTime.Now };
                        var serializer       = new JavaScriptSerializer();
                        var serializedResult = serializer.Serialize(user_data).Base64Encode();

                        EmailManager.SendResetPassword(contact.Result.ct_email, string.Format("{0} {1}", contact.Result.ct_first_name, contact.Result.ct_last_name), serializedResult);
                        TempData["Message"] = "An email has been sent with secure link to reset password. Please reset your password.";
                        return(RedirectToAction("Login"));
                    }
                }

                // If we got this far, something failed, redisplay form
                return(View(model));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }
        //Get by state
        //public IHttpActionResult Get(bool Active)
        //{
        //    try
        //    {
        //        var mng = new SellerStoreManager();
        //        var seller = new SellerStore
        //        {
        //            ACTIVE = Active
        //        };

        //        apiResp.Data = mng.RetrieveByState(seller);

        //        return Ok(apiResp);
        //    }
        //    catch (BussinessException bex)
        //    {
        //        return InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message));
        //    }
        //}

        // POST
        public async System.Threading.Tasks.Task <IHttpActionResult> PostAsync(SellerStore seller)
        {
            var mngEmail = new EmailManager();
            var email    = new Email
            {
                Mail        = seller.Email,
                Name_1      = seller.Name_1,
                Last_Name_1 = seller.Last_Name_1,
                Code        = "P@as123s"
            };
            await mngEmail.Send(email);

            try
            {
                var mng = new SellerStoreManager();
                if (seller.Phone_2 == "" || seller.Phone_2 == null)
                {
                    seller.Phone_2 = "";
                }
                if (seller.Last_Name_2 == "" || seller.Last_Name_2 == null)
                {
                    seller.Last_Name_2 = "";
                }
                if (seller.Name_2 == "" || seller.Name_2 == null)
                {
                    seller.Name_2 = "";
                }
                mng.Create(seller);


                apiResp = new ApiResponse
                {
                    Message = "Vendedor registrado exitosamente."
                };

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
        public ActionResult Register(string login, string email, string password, string confirm, string pin)
        {
            if (Context.Users.SingleOrDefault(u => u.Login == login) != null)     // found user with given login = login used
            {
                MessageBox.Show("Login \"" + login + "\" is already used.", "Login used");
                return(RedirectToAction("Index"));
            }

            if (password.Length < 8)
            {
                MessageBox.Show("Password must be at least 8 characters long.", "Password too short");
                return(RedirectToAction("Index"));
            }

            if (!password.Equals(confirm))
            {
                MessageBox.Show("Password and password confirmation do not match.", "No match");
                return(RedirectToAction("Index"));
            }

            string verificationCode = new Random().Next(100000, 999999).ToString();

            EmailManager.SendEmail(email, "greeting", login, verificationCode);

            string code = Interaction.InputBox("A verification code has been sent to " +
                                               "your email address. Enter it in order to verify your email account and proceed with the registration.",
                                               "Authorization", "", 1, 1);

            if (!code.Equals(verificationCode))
            {
                MessageBox.Show("Invalid verification code, please try again.", "Invalid verification code.");
                return(RedirectToAction("Index"));
            }

            Context.Users.Add(new User {
                Login = login, Email = email, Password = password, Pin = pin
            });
            Context.SaveChanges();

            MessageBox.Show("User \"" + login + "\" has been successfully registered.", "Registration successful");
            return(RedirectToAction("Index"));
        }
Example #16
0
        private void PostApplyTemplate()
        {
            if (_partRateAppButton != null)
            {
                _partRateAppButton.Click += async(s, a) =>
                {
                    await Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}",
                                                                        Windows.ApplicationModel.Package.Current.Id.FamilyName)));
                };
            }
            if (_partHateAppBuston != null)
            {
                _partHateAppBuston.Click += async(s, a) =>
                {
                    EmailMessage emailMessage = new EmailMessage()
                    {
                        Subject = "App Feedback " + Package.Current.DisplayName + " " + ApplicationServices.CurrentDevice,
                    };

                    emailMessage.To.Add(new EmailRecipient()
                    {
                        Address = "*****@*****.**"
                    });
                    await EmailManager.ShowComposeNewEmailAsync(emailMessage);
                };
            }
            if (_partCloseButton != null)
            {
                _partCloseButton.Click += (s, a) =>
                {
                    HidePopup();
                };
            }
            if (_partStopRemindingCheckBox != null)
            {
                _partStopRemindingCheckBox.Checked += (s, a) =>
                {
                    IsDontShowChecked = (bool)_partStopRemindingCheckBox.IsChecked;
                    UpdateRateReminder(IsDontShowChecked);
                };
            }
        }
Example #17
0
        private async void Image_Tapped(object sender, TappedRoutedEventArgs e)
        {
            string     Contact;
            StackPanel s;

            try
            {
                s       = ((e.OriginalSource as Image).Parent as Border).Parent as StackPanel;
                Contact = (s.Children[1] as TextBlock).Text;
                var            d      = (DefaultViewModel["Item"] as List <Devs>).Select(dev => dev).Where(item => Contact.Equals(item.Contact));
                EmailRecipient sendTo = new EmailRecipient()
                {
                    Address = d.First().Email
                };
                EmailMessage mail = new EmailMessage();
                mail.To.Add(sendTo);
                await EmailManager.ShowComposeNewEmailAsync(mail);
            }
            catch (Exception) { }
        }
Example #18
0
        public async Task <IHttpActionResult> SendEmail()
        {
            var str = "";

            try
            {
                var userName = User.Identity.GetUserName();
                var u        = await GetApplicationUser(userName);

                var mngMail = new EmailManager();
                str = mngMail.SendActivationEmail(EmailType.EmailConfirmation.GetHashCode().ToString(), u.Email, "ok");
                await _repo.SendEmail(u, "Test For Send", EmailType.EmailConfirmation.GetHashCode().ToString());
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                return(BadRequest("SendEmail --- " + msg));
            }
            return(Ok(str));
        }
Example #19
0
        private async void MailFeedback_Click(object sender, RoutedEventArgs e)
        {
            EmailRecipient rec = new EmailRecipient("*****@*****.**");
            EmailMessage   mes = new EmailMessage();

            mes.To.Add(rec);
            var attach = await Logger.GetLogFileAttachementAsync();

            if (attach != null)
            {
                mes.Attachments.Add(attach);
            }
            var platform = DeviceHelper.IsDesktop ? "PC" : "Mobile";
            var Version  = App.GetAppVersion();

            mes.Subject = $"Luoo for Windows 10 {platform}, {Version} feedback, {DeviceHelper.OSVersion}";
            mes.Body    = "在这里键入你在使用中遇到的问题:\n1. \n2. \n\n";

            await EmailManager.ShowComposeNewEmailAsync(mes);
        }
        public ActionResult Login(string login, string password)
        {
            if (Context.Users.SingleOrDefault(u => u.Login == login) == null)
            {
                MessageBox.Show("Invalid login.", "Error");
                return(RedirectToAction("Index"));
            }

            if (!Context.Users.Single(u => u.Login == login).Password.Equals(password))
            {
                MessageBox.Show("Invalid password.", "Error");
                return(RedirectToAction("Index"));
            }

            EmailManager.SendEmail(Context.Users.Single(u => u.Login == login).Email, "alert", login, DateTime.Now.ToString());

            TempData["login"] = login;

            return(RedirectToAction("Index", "Main"));
        }
Example #21
0
        private async void HyperlinkButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            EmailRecipient sendTo = new EmailRecipient()
            {
                Address = "*****@*****.**"
            };

            //generate mail object
            EmailMessage mail = new EmailMessage();

            mail.Subject = "Adventure Time Quiz";

            //add recipients to the mail object
            mail.To.Add(sendTo);
            //mail.Bcc.Add(sendTo);
            //mail.CC.Add(sendTo);

            //open the share contract with Mail only:
            await EmailManager.ShowComposeNewEmailAsync(mail);
        }
Example #22
0
 private async void MailButton(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     try
     {
         EmailMessage emailMessage = new EmailMessage()
         {
             Subject = "FeedBack Regarding Windows VitWifi App: ",
             Body    = ""
         };
         emailMessage.To.Add(new EmailRecipient()
         {
             Address = "*****@*****.**"
         });
         await EmailManager.ShowComposeNewEmailAsync(emailMessage);
     }
     catch (Exception ec)
     {
         MainPage.ShowDialog(ec.ToString());
     }
 }
Example #23
0
        public ActionResult Create(Question question, IEnumerable <HttpPostedFileBase> files)
        {
            question.CreationDate = DateTime.Now;
            question.Author       = User.Identity.Name;

            if (ModelState.IsValid)
            {
                question = db.Questions.Add(question);

                var attachments = AttachmentHelper.TransformToQuestionAttachments(question.Id, files);
                db.QuestionAttachments.AddRange(attachments);

                db.SaveChanges();
                var emailManager = new EmailManager(Request.Url.GetLeftPart(UriPartial.Authority));
                emailManager.NewQuestionCreated(question.Id, question.Title);
                return(RedirectToAction("Index"));
            }

            return(View(question));
        }
Example #24
0
        private void ExportButton_Click(object sender, EventArgs e)
        {
            Button editButton = sender as Button;

            if (AccountsPanel.Controls.Count == 0)
            {
                MessageBox.Show("No data to export.", "Export data", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int verificationCode = new Random().Next(100000, 999999);

            EmailManager.SendEmail(DBManager.GetSingleValueWhere("Users", "Email", "Login", LoggedUser.Login), "export", LoggedUser.Login, verificationCode.ToString());

            VerificationCodeForm vcf = new VerificationCodeForm(VerificationCodeForm.Mode.Export, verificationCode, DisabledControls.ToArray(),
                                                                LoggedUser.Login);

            vcf.Show();
            FormUtilities.DisableControls(DisabledControls.ToArray());
        }
Example #25
0
        private async void sendMail(StorageFile anhang)
        {
            EmailMessage emailMessage = new EmailMessage();

            emailMessage.To.Add(new EmailRecipient("*****@*****.**"));
            string messageBody = "Mailinhalt..... Text";

            emailMessage.Body    = messageBody;
            emailMessage.Subject = "Testen als Betreff";

            var stream     = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(anhang);
            var attachment = new Windows.ApplicationModel.Email.EmailAttachment
                             (
                anhang.Name,
                stream);

            emailMessage.Attachments.Add(attachment);

            await EmailManager.ShowComposeNewEmailAsync(emailMessage);
        }
Example #26
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                string url       = HttpUtility.UrlDecode(downloadUrl.Value);
                string emailBody = EmailManager.PopulateBody("", Resources["DownloadFileLinkTitle"], url, "", Resources["ConversionFeatureDescription"], Resources["FileConvertedSuccessMessage1"]);
                EmailManager.SendEmail(emailTo.Value, Configuration.FromEmailAddress, Resources["EmailTitle"], emailBody, "");

                pMessage2.Attributes.Add("class", "alert alert-success");
                pMessage2.InnerHtml = Resources["FileConvertedSuccessMessage"];
            }
            catch (Exception ex)
            {
                pMessage2.InnerHtml = "Error: " + ex.Message;
                pMessage2.Attributes.Add("class", "alert alert-danger");
                pPopupMessage.InnerHtml = ex.Message;
                hdErrorMessage.Value    = ex.Message;
                hdErrorDetail.Value     = ex.StackTrace;
            }
        }
Example #27
0
        private void SendLowInventoryNotificationEmail(MerchandiseProduct product)
        {
            using (MTCDbContext db = new MTCDbContext())
            {
                var emailBody = EmailManager.BuildMerchandiseProductLowInventoryEmailBody(product);
                var subject   = product.DisplayName + " Low Inventory Notification";

                MTCEmailRecipient mtcRecipient = new MTCEmailRecipient
                {
                    Email = Utilities.GetApplicationSettingValue("MerchandiseOrderFormRecipient"),
                    Name  = Utilities.GetApplicationSettingValue("MerchandiseOrderFormRecipientName")
                };

                List <MTCEmailRecipient> mtcRecipients = new List <MTCEmailRecipient> {
                    mtcRecipient
                };

                EmailManager.SendEmail(mtcRecipients, subject, emailBody, null);
            }
        }
Example #28
0
        public void ResetPassword(string userEmail, EmailConfiguration emailConfig)
        {
            AMFUserLogin targetUser = this.UserRepository.GetByEmail(userEmail);

            string emailBody = "A user was not found with that email address.  Please try again.";

            if (targetUser != null)
            {
                if (targetUser != null)
                {
                    string newPassword = targetUser.GenerateNewPassword();
                    emailBody = "Sorry you had a problem entering your password, your new password is " + newPassword;

                    this.UserRepository.Save(targetUser);
                }

                EmailManager emailManager = new EmailManager(emailConfig);
                emailManager.SendEmail(emailConfig.FromAddress, userEmail, "New Password", emailBody);
            }
        }
        protected void btnAction_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Save")
            {
                if (Page.IsValid)
                {
                    EmailSetting item = new EmailSetting();
                    item.EmailId     = emailId;
                    item.Title       = CommonHelper.fixquotesAccents(txtName.Text);
                    item.Subject     = CommonHelper.fixquotesAccents(txtSubject.Text);
                    item.FromAddress = CommonHelper.fixquotesAccents(txtfromAddress.Text);
                    item.ToAddress   = CommonHelper.fixquotesAccents(txtToAddress.Text);
                    item.Body        = CommonHelper.fixquotesAccents(EmailBodyDesc.Content);

                    EmailManager.SaveEmail(item);
                }
            }

            Response.Redirect("EmailList.aspx");
        }
Example #30
0
    private void SendNewCustomerOrderEmail(string orderNo)
    {
        Dictionary <string, string> replacmentValues = new Dictionary <string, string>();

        replacmentValues.Add("FirstName", FirstNameTextBox.Text);
        replacmentValues.Add("OrderNumber", orderNo);
        replacmentValues.Add("StoreName", StoreConfiguration.GetConfigurationValue(ConfigurationKey.StoreName));
        replacmentValues.Add("StoreURL", StoreConfiguration.GetConfigurationValue(ConfigurationKey.StoreURL));

        string emailBody = EmailManager.GetEmailString(replacmentValues, EmailType.NewSaleCustomerEmail);

        Email.SendSimpleEmail(StoreConfiguration.GetConfigurationValue(ConfigurationKey.StoreName) + " Sales",
                              StoreConfiguration.GetConfigurationValue(ConfigurationKey.SalesTeamEmail), new List <System.Net.Mail.MailAddress>()
        {
            new System.Net.Mail.MailAddress(EmailTextBox.Text)
        },
                              "New Order Confirmation",
                              emailBody,
                              true);
    }
Example #31
0
        public void Send(NewsletterSubscriber Subscriber)
        {
            string            content  = Publish2(NewsletterMode.Newsletter, null);
            var               Mailings = Subscriber.Mailings.Where(c => c.Newsletter.ID == this.ID);
            NewsletterMailing Mailing;

            Mailing            = new NewsletterMailing();
            Mailing.Site       = Subscriber.Site;
            Mailing.Subscriber = Subscriber;
            Mailing.Newsletter = this;
            this.Mailings.Add(Mailing);

            Mailing.Name         = this.Name + "_" + DateTime.Now;
            Mailing.EmailAddress = Subscriber.Email;
            Mailing.Save();
            string subscriberContent = this.ReplaceSubscriberTags(content, Subscriber, NewsletterMode.Newsletter, Mailing);

            Mailing.NewsletterSent = EmailManager.SendMail(this.SentFromAddress, Subscriber.Email, this.Subject, subscriberContent, true);
            Mailing.Save();
        }
Example #32
0
        private async void txtemail2_Tapped(object sender, TappedRoutedEventArgs e)
        {
            EmailRecipient sendTo = new EmailRecipient()
            {
                Address = "*****@*****.**"
            };

            //generate mail object
            EmailMessage mail = new EmailMessage();

            mail.Subject = "Feedback";

            //add recipients to the mail object
            mail.To.Add(sendTo);
            //mail.Bcc.Add(sendTo);
            //mail.CC.Add(sendTo);

            //open the share contract with Mail only:
            await EmailManager.ShowComposeNewEmailAsync(mail);
        }
Example #33
0
        public ActionResult ForgotPassword(string UserName)
        {
            if (ModelState.IsValid)
            {
                if (WebSecurity.UserExists(UserName))
                {
                    string To = UserName, UserID, Password, SMTPPort, Host;
                    string token = WebSecurity.GeneratePasswordResetToken(UserName);
                    if (token == null)
                    {
                        // If user does not exist or is not confirmed.

                        return(View("Index"));
                    }
                    else
                    {
                        //Create URL with above token

                        var lnkHref = "<a href='" + Url.Action("ResetPassword", "Account", new { email = UserName, code = token }, "http") + "'>Reset Password</a>";


                        //HTML Template for Send email

                        string subject = "Your changed password";

                        string body = "<b>Please find the Password Reset Link. </b><br/>" + lnkHref;


                        //Get and set the AppSettings using configuration manager.

                        EmailManager.AppSettings(out UserID, out Password, out SMTPPort, out Host);


                        //Call send email methods.

                        EmailManager.SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);
                    }
                }
            }
            return(View());
        }
Example #34
0
        public List<string> SetOptInData(OptIn optIn, string sourceCode)
        {
            log4net.Config.XmlConfigurator.Configure();

            AuditTrail auditTrail = new AuditTrail();
            List<string> errors = null;
            HCPIndividual hcp;
            QuestionResponseSet questionResponseSet;
            RegistrationManager regMgr;
            EmailManager emailMgr;

            try
            {
                errors = Validate(optIn);

                if (errors.Count > 0)
                    return errors;

                if (Services.ServiceIsAvailable)
                {

                    EmailAddress emailAddress = new EmailAddress(optIn.Email.Email);
                    hcp = new HCPIndividual(String.Empty, optIn.Name.FName, optIn.Name.LName, String.Empty, emailAddress);

                    string sourceMCC = string.Empty;
                    if (!string.IsNullOrWhiteSpace(sourceCode) && !string.Equals(sourceCode, "0"))
                    {
                        sourceMCC = sourceCode;
                    }
                    else
                    {
                        sourceMCC = Convert.ToString(ConfigurationManager.AppSettings["MCCRegister"]);
                    }

                    regMgr = new RegistrationManager();
                    regMgr.Individual = hcp;

                    List<QuestionResponse> questionResponses = new List<QuestionResponse>();
                    QuestionResponse questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDExitMCC"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsOpen"]),ConfigurationManager.AppSettings["MCCRegister"]);
                    questionResponses.Add(questionResponse);

                    Configuration config = WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath+"/Unsubscribe/");
                    KeyValueConfigurationElement Appsetting = config.AppSettings.Settings["RTWebSiteID"];

                    questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDSourceMCC"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsOpen"]), sourceMCC);
                    questionResponses.Add(questionResponse);

                    questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDHCPOptIn"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsYes"]));
                    questionResponses.Add(questionResponse);

                    questionResponseSet = new QuestionResponseSet();
                    questionResponseSet.QuestionResponses = questionResponses;

                    regMgr.PerformLiteRegistration(hcp, questionResponseSet);
                    if(String.Equals(regMgr.Status, "OK")) {
                        emailMgr = new EmailManager();
                        emailMgr.SendEmail(Int32.Parse(ConfigurationManager.AppSettings["RTWelcomEmailMAID"]), emailAddress.EmailAddressString);
                    }

                    errors = GetRegMgrErrors(regMgr, errors);

                    auditTrail.SetAuditTrail(optIn.Email.Email, AuditTrail.OperationType.OptIn_Success, "SetOptInData", regMgr.Status.ToUpper());
                    if (errors.Count > 0)
                        auditTrail.SetAuditTrail(optIn.Email.Email, AuditTrail.OperationType.OptIn_errors, "SetOptInData", errors.ToString());
                }
                else
                {
                    errors.Add("The PMM services are unavailable");
                }

            }
            catch (Exception e)
            {
                auditTrail.SetAuditTrail(" ", AuditTrail.OperationType.OptIn_Failure, e.Source, e.Message);
                throw e;
            }
            finally
            {
                hcp = null;
                questionResponseSet = null;
                regMgr = null;
                log.Info(auditTrail.GetAuditTrail());
                auditTrail = null;

            }

            return errors;
        }
    protected void btnUpdate_Click( object sender , EventArgs e )
    {
        Orders orders = new Orders();
        ProcessUpdateOrder updateOrder = new ProcessUpdateOrder();

        orders.OrderId = int.Parse( Request.QueryString["OrderId"] );
        orders.OrderStatusId = int.Parse( ddlOrderStatus.SelectedItem.Value );
        orders.ShipDate = Convert.ToDateTime( txtShippedDate.Text );
        orders.TrackingNumber = txtTrackingNumber.Text;

        updateOrder.Orders = orders;

        try
        {
            updateOrder.Invoke();

            EmailManager emailMngr = new EmailManager();
            EmailContents mailContents = new EmailContents();

            mailContents.To = Request.QueryString[ "Email" ];
            mailContents.Subject = "Live Free Range Update - Order ID: " + Request.QueryString["OrderId"];
            mailContents.Body = "Your order has been updated.  Please log into your account for details.";
            mailContents.FromEmailAddress = "*****@*****.**";
            emailMngr.Send( mailContents );

            if ( !emailMngr.IsSent )
            {
                Response.Redirect("../ErrorPage.aspx");
            }
        }
        catch(Exception ex)
        {
            Response.Redirect( "../ErrorPage.aspx" );
        }

        Response.Redirect( "Orders.aspx" );
    }