예제 #1
0
        public static bool ConfirmationEmail(EmailRequest requestModel, Guid uniqueId)
        {
            bool result = false;

            EmailData model = new EmailData();

            model.FromEmail = ("000000000000000");
            model.Subject = requestModel.Subject;
            model.Message = "Hey there!" + Environment.NewLine + "Before you can enjoy the benefits of the site, please take the time to confirm your email. Please follow this link:"
                + Environment.NewLine + _baseURL + "/public/confirmation/" + uniqueId + Environment.NewLine + Environment.NewLine;
            model.Message += requestModel.Message;

            model.To = requestModel.Email;

            Send(model);

            if (model != null)
            {
                result = true;
            }

            return result;
        }
예제 #2
0
        public static bool resetPasswordEmail(EmailRequest requestModel, Guid uniqueId)
        {
            bool result = false;

            string page = "/account/Forgotpassword/";

            EmailData model = new EmailData();

            model.FromEmail = ("000000000000000");
            model.Subject = requestModel.Subject;
            model.Message = requestModel.Message;

            model.Message = "Hey, there!" + Environment.NewLine + "A request has been made to reset your password. Please follow this link:"
                + Environment.NewLine + _baseURL + page + uniqueId + Environment.NewLine + Environment.NewLine;
            model.Message += requestModel.Message;

            model.To = requestModel.Email;

            Send(model);

            if (model != null)
            {
                result = true;
            }

            return result;
        }
예제 #3
0
        private static EmailData FillEmailModel(string fromEmail, string name, string subject
            , string message, string recipientEmail)
        {
            EmailData emailModel = new EmailData();
            emailModel.FromEmail = fromEmail;
            emailModel.Name = name;
            emailModel.Subject = subject;
            emailModel.Message = message;
            emailModel.To = (recipientEmail);

            return emailModel;
        }
예제 #4
0
        private static void Send(EmailData model)
        {
            string To = model.To;
            string From = model.FromEmail;
            string Name = model.Name;
            string Subject = model.Subject;
            string Message = model.Message;
            string CC = model.CC;
            string BCC = model.BCC; //for later implementation

            var message = new SendGridMessage();

            if (CC != null)
            {
                message.AddCc(CC);
            }

            message.AddTo(To);

            message.From = new MailAddress(From, Name); //ensure name is optional?
            message.Subject = Subject;
            message.Text = Message;

            var credentials = new NetworkCredential(_sendGridEmailUserName, _sendGridEmailPassword);

                var transportWeb = new SendGrid.Web(credentials);

            try
            {
                transportWeb.DeliverAsync(message);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #5
0
        public static void SendContactUs(CommAddRequest requestModel)
        {
            //this method should accept contact add request and create email data
            //using the data within contact add request
            EmailData model = new EmailData();

            //put data into email data

            model.FromEmail = requestModel.Email;
            model.Name = requestModel.Name;
            model.Subject = requestModel.Subject;
            model.Message = requestModel.Message;

            //The intro message needs to be sent to Admin ONLY.
            //plus '/n' formats the text size and 'Environment.NewLine' fails to insert new line as expected.

            //model.Message = "Hello Admin," + Environment.NewLine + "This email has been sent to you from a Site User who filled out your 'Contact Us' form." + Environment.NewLine + Environment.NewLine;
            //model.Message += requestModel.Message;

            model.To = ("000000000000000");
            model.CC = requestModel.Email;

            Send(model);
        }