Esempio n. 1
0
        public async Task SendEmail(EmailModel emailData)
        {
            var email = new MailMessage(emailData.FromEmail, emailData.ToEmail)
            {
                Subject    = emailData.Subject,
                Body       = emailData.Body,
                IsBodyHtml = true
            };

            var svc = new PersonalEmail();
            await svc.SendAsync(email);
        }
Esempio n. 2
0
        public static async Task ComposeEmailAsync(RegisterViewModel model, string callbackUrl)
        {
            try
            {
                var senderEmail = $"Blog Admin<{ConfiguredEmail}>";
                var mailMsg     = new MailMessage(senderEmail, model.Email)
                {
                    Subject    = "Reset Password",
                    Body       = $"Reset your password by clicking <a href=\"{callbackUrl}\">here</a>",
                    IsBodyHtml = true
                };

                var svc = new PersonalEmail();
                await svc.SendAsync(mailMsg);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
        }
Esempio n. 3
0
        public static async Task ComposeEmailAsync(EmailModel email)
        {
            try
            {
                var senderEmail = $"{email.FromEmail}<{ConfiguredEmail}>";
                var mailMsg     = new MailMessage(senderEmail, ConfiguredEmail)
                {
                    Subject    = email.Subject,
                    Body       = $"<strong>{email.FromName} has sent you the following message </strong> <hr/> {email.Body}",
                    IsBodyHtml = true
                };

                var svc = new PersonalEmail();
                await svc.SendAsync(mailMsg);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
        }
Esempio n. 4
0
        public static async Task ComposeEmailAsync(EmailModel email)
        {
            var strFormat = "<p>You have a message From: <bold>{0}</bold> ({1})</p><p>Message:</p><p>{2}</p>";

            try
            {
                var senderEmail = $"{email.FromEmail}<{EmailSendFrom}>";
                var mailMsg     = new MailMessage(senderEmail, EmailSendTo);
                mailMsg.Subject    = "IraNye Site Contact-Me Message from <strong>{email.FromEmail}</strong>: " + email.Subject;
                mailMsg.Body       = string.Format(strFormat, email.FromName, email.FromEmail, email.Body);
                mailMsg.IsBodyHtml = true;

                var svc = new PersonalEmail();
                await svc.SendAsync(mailMsg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
        }
Esempio n. 5
0
        public static async Task ComposeForgotPasswordEmailAsync(ForgotPasswordViewModel model, string callbackUrl)
        {
            try
            {
                var senderEmail = $"Bugtracker<{ConfiguredEmail}>";
                var mailMsg     = new MailMessage(senderEmail, model.Email)
                {
                    Subject    = "Reset Password",
                    Body       = $"Please reset your password by clicking <a href=\"{callbackUrl}\"> here",
                    IsBodyHtml = true
                };

                var svc = new PersonalEmail();
                await svc.SendAsync(mailMsg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
        }
Esempio n. 6
0
        public static async Task ComposeEmailAsync(RegisterViewModel model, string callbackUrl)
        {
            try
            {
                var senderEmail    = $"Web Admin<{EmailSendFrom}>";
                var recipientEmail = model.Email;
                var mailMsg        = new MailMessage(senderEmail, recipientEmail)
                {
                    Subject    = "Confirm your Account",
                    Body       = $"Please confirm your Account (at BugTracker) by clicking <a href=\"{callbackUrl}\"here</a>",
                    IsBodyHtml = true
                };

                var svc = new PersonalEmail();
                await svc.SendAsync(mailMsg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
        }
Esempio n. 7
0
        public static async Task ComposeEmailAsync(ForgotPasswordViewModel model, string callbackUrl)
        {
            var strFormat = "<p>You have a message From: <bold>{0}</bold> ({1})</p><p>Message:</p><p>{2}</p>";
            var appName   = "BugTracker";

            try
            {
                var senderEmail    = $"{EmailSendFrom}<{EmailSendFrom}>";
                var recipientEmail = model.Email;
                var mailMsg        = new MailMessage(senderEmail, recipientEmail);
                mailMsg.Subject    = $"({appName}) Forgot Password";
                mailMsg.Body       = callbackUrl;
                mailMsg.IsBodyHtml = true;

                var svc = new PersonalEmail();
                await svc.SendAsync(mailMsg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await Task.FromResult(0);
            }
        }
Esempio n. 8
0
        public async System.Threading.Tasks.Task SendNotificationAsync(string shortbody, string notification, string update, int ticketnum, string devid)
        {
            var             from       = "BugTracker<*****@*****.**>";
            var             userId     = HttpContext.Current.User.Identity.GetUserId();
            ApplicationUser user       = db.Users.Find(userId);
            var             emailfrom  = user.Email;
            ApplicationUser userto     = db.Users.Find(devid);
            var             emailto    = userto.Email;
            var             ticketname = db.Tickets.Find(ticketnum).Title;
            var             body       = $"{notification} {ticketname}. Please contact a supervisor for further questions.";

            var email = new MailMessage(from, emailto)
            {
                Subject    = "Ticket changes",
                Body       = body,
                IsBodyHtml = true
            };

            var svc = new PersonalEmail();
            await svc.SendAsync(email);

            var dropbody = notification + " " + ticketname;
            var record   = new TicketNotification
            {
                ShortBody        = shortbody,
                TicketId         = ticketnum,
                SenderUserId     = userId,
                RecipientUserId  = devid,
                Created          = DateTime.Now,
                Comfirmed        = false,
                NotifocationBody = dropbody,
            };

            db.TicketNotifications.Add(record);
            db.SaveChanges();
        }