Exemplo n.º 1
0
        private void sendShippingEmails(ShippingNoticeVM vm)
        {
            EmailClient email = EmailClient.Create();

            string confirmationBody = RenderPartialToString(this, "__ShippingConfirmation", vm);
            string notificationBody = RenderPartialToString(this, "__ShippingNotification", vm);

            MailMessage confirmationMessage = new MailMessage
            {
                To         = { new MailAddress(vm.SenderEmail, vm.SenderUsername) },
                CC         = { new MailAddress("*****@*****.**") },
                Bcc        = { new MailAddress("*****@*****.**") },
                From       = new MailAddress("*****@*****.**", "BeerItForward"),
                Subject    = $"{vm.ExchangeName} Shipping Confirmation",
                Body       = confirmationBody,
                IsBodyHtml = true
            };

            MailMessage notificationMessage = new MailMessage
            {
                To         = { new MailAddress(vm.RecipientEmail, vm.RecipientUsername) },
                CC         = { new MailAddress("*****@*****.**") },
                Bcc        = { new MailAddress("*****@*****.**") },
                From       = new MailAddress("*****@*****.**", "BeerItForward"),
                Subject    = $"{vm.ExchangeName} Shipping Notification",
                Body       = notificationBody,
                IsBodyHtml = true
            };

#if (DEBUG)
#else
            email.SMTP.Send(confirmationMessage);
            email.SMTP.Send(notificationMessage);
#endif
        }
Exemplo n.º 2
0
        private void createUserConfirmationEmail(string id)
        {
            EmailClient email = EmailClient.Create();

            var user = DAL.Context.Users.Where(x => x.Id == id).Select(x => new { Email = x.Email, Profile = x.Profile }).FirstOrDefault();

            if (user?.Profile == null)
            {
                return;
            }

            string phoneNumber = user.Profile.PhoneNumber?.PadLeft(10, ' ') ?? "          ";

            ProfileVM vm = new ProfileVM {
                Id            = id,
                Name          = user.Profile.FullName,
                Address       = user.Profile.Address,
                City          = user.Profile.City,
                State         = user.Profile.State,
                Zip           = user.Profile.Zip,
                DeliveryNotes = user.Profile.DeliveryNotes,

                RedditUsername  = user.Profile.RedditUsername,
                UntappdUsername = user.Profile.UntappdUsername,

                References = user.Profile.References,
                //Wishlist = user.Profile.Wishlist,
                Comments = user.Profile.Comments,

                Piney  = user.Profile.Piney,
                Juicy  = user.Profile.Juicy,
                Tart   = user.Profile.Tart,
                Funky  = user.Profile.Funky,
                Malty  = user.Profile.Malty,
                Roasty = user.Profile.Roasty,
                Sweet  = user.Profile.Sweet,
                Smokey = user.Profile.Smokey,
                Spicy  = user.Profile.Spicy,
                Crisp  = user.Profile.Crisp,


                Phone = $"{phoneNumber.Substring(0, 3)}-{phoneNumber.Substring(3, 3)}-{phoneNumber.Substring(6, 4)}",
                Email = user.Email,

                UpdateDate = user.Profile.UpdateDate
            };

            string body = "<p>Thanks for updating your profile. Here's what we have on record for you:</p>" + RenderPartialToString(this, "__ViewProfile", vm);

            MailMessage message = new MailMessage {
                To         = { new MailAddress(user.Email, user.Profile.FullName) },
                Bcc        = { new MailAddress("*****@*****.**"), new MailAddress("*****@*****.**") },
                From       = new MailAddress("*****@*****.**", "BeerItForward"),
                Subject    = "BeerItForward Profile Complete",
                Body       = body,
                IsBodyHtml = true
            };

            email.SMTP.Send(message);
        }
Exemplo n.º 3
0
        // GET: Error
        public ActionResult Index()
        {
            Exception lastError = Server.GetLastError()?.GetBaseException();

            bool emailSent = false;

            if (lastError != null)
            {
                try {
                    EmailClient email = EmailClient.Create();

                    MailMessage message = new MailMessage {
                        To         = { new MailAddress("*****@*****.**") },
                        From       = new MailAddress("*****@*****.**", "BeerItForward"),
                        Subject    = $"BiF Error: {lastError.Message}",
                        Body       = $"<p>{lastError.Message}</p><p>{lastError.StackTrace}</p>",
                        IsBodyHtml = true
                    };

                    email.SMTP.Send(message);
                    emailSent = true;
                }
                catch {
                    // ignored
                }
            }

            string baseMessage =
                "<p>Well, this is embarassing.  We weren't expecting an unexpected error.  Not now.  Not like this.</p>";
            string notfiyMessage = emailSent
                ? "<p>Don't worry, we've called the police, and ambulance, and the National Guard.  Everything will be OK.</p>" : "";
            string stackMessage = $"<!-- {lastError?.Message}\n {lastError?.StackTrace} -->";

            ViewBag.MessageTitle = "Ummmm.... Error?";
            ViewBag.Message      = baseMessage + notfiyMessage + stackMessage;


            return(View("Message"));
        }