Ejemplo n.º 1
24
        public void SendAdminEmail(Usuario usuario)
        {
            // Create the email object first, then add the properties.
            var myMessage = new SendGridMessage();

            // Add the message properties.
            myMessage.From = new MailAddress("*****@*****.**", "Projeto Joule");

            // Add multiple addresses to the To field.
            List<string> recipients = new List<string>
            {
                @"*****@*****.**"
            };

            myMessage.AddTo(recipients);

            myMessage.Subject = "Novo Usuário!";

            myMessage.Html += string.Format(@"<table>
            <tr><th>Nome</th><th>Sobrenome</th><th>Email</th>
            <th>Telefone</th><th>Endereço</th><th>Cidade</th>
            <th>Estado</th><th>País</th><th>Programas</th>
            <th>Profile</th><th>Sobre</th></tr>
            <tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>
            <td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td>
            <td>{9}</td><td>{10}</td></tr></table>", usuario.FirstName, usuario.LastName, usuario.Email,
            usuario.PhoneNumber, usuario.Address, usuario.City,
            usuario.State, usuario.Country, string.Join(",", usuario.Programs.ToArray()),
            usuario.CurrentProfile, usuario.About);

            this.SendEmail(myMessage);
        }
Ejemplo n.º 2
4
        public async Task<ProviderProcessResult> Process(Message message)
        {
            try
            {
                var msg = new SendGridMessage();
                msg.AddTo(message.To);
                msg.From = new MailAddress(message.Application.EmailFromAddress, message.Application.EmailFromFullName);
                msg.Subject = message.Subject;
                msg.Html = message.Content;

                var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridSecretKey"]);

                await transportWeb.DeliverAsync(msg);

                return new ProviderProcessResult { IsSuccess = true };
            }
            catch (Exceptions.InvalidApiRequestException ex)
            {
                return new ProviderProcessResult { IsSuccess = false, ErrorMessage = String.Join(",", ex.Errors), ErrorDetails = ex.ToString() };
            }
            catch (Exception ex)
            {
                return new ProviderProcessResult { IsSuccess = false, ErrorMessage = ex.Message, ErrorDetails = ex.ToString() };
            }
        }
Ejemplo n.º 3
0
		private async Task SendRestorePasswordEmail(string requestId, ApplicationUser user)
		{
			var url = Url.Action("SetNewPassword", "RestorePassword", new { requestId }, "https");

			var message = new SendGridMessage();
			message.AddTo(user.Email);
			message.From = new MailAddress("*****@*****.**", "Добрый робот uLearn");
			message.Subject = "Восстановление пароля uLearn";
			message.Html = "Чтобы изменить пароль к аккаунту " + user.UserName + ", перейдите по ссылке: <a href=\"" + url + "\">" + url + "</a>";

			var login = ConfigurationManager.AppSettings["SendGrid.Login"];
			var password = ConfigurationManager.AppSettings["SendGrid.Password"];
			var credentials = new NetworkCredential(login, password);

			var transport = new SendGrid.Web(credentials);

			try
			{
				await transport.DeliverAsync(message);
			}
			catch (InvalidApiRequestException ex)
			{
				throw new Exception(ex.Message + ":\n\n" + string.Join("\n", ex.Errors), ex);
			}
		}
Ejemplo n.º 4
0
        // Use NuGet to install SendGrid (Basic C# client lib)
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGrid.SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From    = new System.Net.Mail.MailAddress("*****@*****.**", "QuizBee Admin");
            myMessage.Subject = message.Subject;
            myMessage.Text    = message.Body;
            myMessage.Html    = message.Body;

            var credentials = new NetworkCredential("*****@*****.**", "Gvb@Admin");


            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 5
0
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task ConfigSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();
            myMessage.AddTo(message.Destination);
            myMessage.From = new MailAddress(this.fromAddress, "NinjaHive System");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            // Create a Web transport for sending email.
            var transportWeb = new Web(this.credentials);

            // Send the email.
            try
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            //http://stackoverflow.com/questions/28878924/bad-request-check-errors-for-a-list-of-errors-returned-by-the-api-at-sendgrid
            catch (InvalidApiRequestException ex)
            {
                var errorDetails = new StringBuilder();

                errorDetails.Append("ResponseStatusCode: " + ex.ResponseStatusCode + ".   ");
                for (int i = 0; i < ex.Errors.Count(); i++)
                {
                    errorDetails.Append($" -- Error #{i} : {ex.Errors[i]}");
                }

                throw new ApplicationException(errorDetails.ToString(), ex);
            }
        }
        private async Task<string> SendEmail(string emailTo, string emailFrom, string fromUserId,
            string toUserName, string inviteCode)
        {
            var fromUserName = db.Users.Find(fromUserId).FirstName + " " + db.Users.Find(fromUserId).LastName;
            var Household = db.Users.Find(fromUserId).Household;
            //string url = "http://localhost:59490/"; //Address of the local host; modify as needed.
            string url = "http://budgetmaster1.azurewebsites.net/"; //Set to URL of online application.
            var body = toUserName + " ,\r\r\r" + fromUserName + " has invited you to join the '" +
                    Household + "' Household in Budget Master! Your invitation code is: " + inviteCode +
                    ". Please go to " + url + ", choose 'Register' in the menu, and enter your information, " +
                    "including the invitation code.";

            var appSettings = ConfigurationManager.AppSettings;
            var credentials = new NetworkCredential(appSettings["SendGridUserName"], appSettings["SendGridPassword"]);
            SendGridMessage message = new SendGridMessage();
            message.AddTo(emailTo);
            message.From = new MailAddress(emailFrom, fromUserName);
            message.Subject = "Invitation to Budget Master";
            message.Text = body;
            var transportWeb = new Web(credentials);
            await transportWeb.DeliverAsync(message);
            var result = "An e-mail invitation to the household has been delivered to " + emailTo + ".";

            return result;
        }
Ejemplo n.º 7
0
        private Task ConfigSendGridAsync(IdentityMessage message)
        {
            var myMessage        = new SendGrid.SendGridMessage();
            var emailOrigin      = ConfigurationManager.AppSettings["mailAddress"];
            var emailDisplayName = ConfigurationManager.AppSettings["mailDisplayName"];

            myMessage.From = new System.Net.Mail.MailAddress(emailOrigin, emailDisplayName);
            myMessage.AddTo(message.Destination);
            myMessage.Subject = message.Subject;
            myMessage.Text    = message.Body;
            myMessage.Html    = message.Body;

            var credentials = new NetworkCredential(
                ConfigurationManager.AppSettings["mailAccount"],
                ConfigurationManager.AppSettings["mailPassword"]
                );

            var transWeb = new Web(credentials);

            if (transWeb != null)
            {
                return(transWeb.DeliverAsync(myMessage));
            }
            else
            {
                return(Task.FromResult(0));
            }
        }
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Gada");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential(ConfigurationManager.AppSettings["sgUsername"],
                                                    ConfigurationManager.AppSettings["sgPassword"]);

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 9
0
        // Implementação do SendGrid
        private Task ConfigSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();
            myMessage.AddTo(message.Destination);
            myMessage.From = new MailAddress("*****@*****.**", "Admin do Portal");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential(ConfigurationManager.AppSettings["mailAccount"], ConfigurationManager.AppSettings["mailPassword"]);

            // Criar um transport web para envio de e-mail
            var transportWeb = new Web(credentials);

            // Enviar o e-mail
            if (transportWeb != null)
            {
                var x = transportWeb.DeliverAsync(myMessage);
                return x;
            }
            else
            {
                return Task.FromResult(0);
            }
        }
Ejemplo n.º 10
0
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new MailAddress(
                AppSettingsService.NoReplyEmail,
                AppSettingsService.NoReplyFullname);
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential(
                AppSettingsService.EmailServiceAccount,
                AppSettingsService.EmailServicePassword);

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 11
0
        //public ActionResult postServiceRequest()
        //{

        //    var myMessage = new SendGrid.SendGridMessage();
        //    var contractors = db.Contractors.ToList();
        //    var servicerequests = db.ServiceRequests.ToList();
        //string name = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt");
        //string pass = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");
        //    List<String> recipients = new List<String> { };

        //    foreach (var i in contractors)
        //    {

        //        recipients.Add(i.email);

        //    };

        //    foreach (var i in servicerequests)
        //    {
        //        if(i.posted == false)
        //        {
        //            myMessage.AddTo(recipients);
        //            myMessage.From = new MailAddress("*****@*****.**", "Admin");
        //            myMessage.Subject = "New Service Request Posting!!";
        //            string url = "http://*****:*****@"C:\Users\erick\Desktop\Credentials\name.txt");
            string        pass            = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");
            var           contractors     = db.Contractors.ToList();
            var           homeowners      = db.Homeowners.ToList();
            var           servicerequests = db.ServiceRequests.ToList();
            List <String> recipients      = new List <String> {
            };
            string identity = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (identity == null)
            {
                return(RedirectToAction("Post_must_be_logged", "Email"));
            }

            var person = db.Homeowners.Where(x => x.UserId == identity).SingleOrDefault();

            foreach (var i in contractors)
            {
                recipients.Add(i.email);
            }
            ;

            foreach (var user in db.Users)
            {
                if (user.Id == identity)
                {
                    foreach (var i in servicerequests)
                    {
                        if (id == i.ID)
                        {
                            if (i.posted == false)
                            {
                                myMessage.AddTo(recipients);
                                myMessage.From    = new MailAddress("*****@*****.**", "Admin");
                                myMessage.Subject = "New Service Request Posting!!";
                                string url     = "http://localhost:14703/ServiceRequests/ContractorAcceptance/" + i.ID;
                                string message = "Job Location: <br>" + i.Address + "<br>" + i.City + "<br>" + i.State + "<br>" + i.Zip + "<br>" + "<br>" + "Job Description: <br>" + i.Description + "<br>" + "<br>" + "Bid price: <br>$" + i.Bid + "<br>" + "<br>" + "Must be completed by: <br>" + i.CompletionDeadline + "<br>" + "<br>" + "Date Posted: <br>" + i.PostedDate + "<br>" + "<br>" + "To accept job, click on link below: <br><a href =" + url + "> Click Here </a>";
                                myMessage.Html = message;
                                var credentials  = new NetworkCredential(name, pass);
                                var transportWeb = new SendGrid.Web(credentials);
                                transportWeb.DeliverAsync(myMessage);
                                i.posted        = true;
                                i.ServiceNumber = i.ID;
                                i.Confirmed     = false;
                            }

                            else
                            {
                                return(RedirectToAction("DuplicatePost", "ServiceRequests"));
                            }
                        }
                    }
                }
            }
            db.SaveChanges();
            return(RedirectToAction("About", "Home"));
        }
Ejemplo n.º 12
0
        public ActionResult sendContractorMail()
        {
            db = new ApplicationDbContext();
            var    myMessage = new SendGrid.SendGridMessage();
            string name      = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt");
            string pass      = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");

            List <String> recipients = new List <String> {
            };

            foreach (var i in db.Contractors)
            {
                recipients.Add(i.email);
            }
            ;

            myMessage.AddTo(recipients);
            myMessage.From    = new MailAddress("*****@*****.**", "Joe Johnson");
            myMessage.Subject = "New Service Request Posting!!";
            myMessage.Text    = "Service request:";
            var credentials  = new NetworkCredential(name, pass);
            var transportWeb = new SendGrid.Web(credentials);

            transportWeb.DeliverAsync(myMessage);

            return(RedirectToAction("About", "Home"));
        }
Ejemplo n.º 13
0
        public ActionResult sendMailNow()///(string message)
        {
            db = new ApplicationDbContext();
            var    myMessage = new SendGrid.SendGridMessage();
            string name      = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt");
            string pass      = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");

            List <String> recipients = new List <String> {
            };

            //{
            //@"Changa Chimp <*****@*****.**>",
            //@"Penny Wise <*****@*****.**>",
            //@"E. Matts <*****@*****.**>",
            //};

            foreach (var i in db.Homeowners)
            {
                recipients.Add(i.email);
            }
            ;

            myMessage.AddTo(recipients);
            myMessage.From    = new MailAddress("*****@*****.**", "Joe Johnson");
            myMessage.Subject = "Sending with SendGrid is Fun";
            //myMessage.Html = "<p>Hello World!</p>";
            myMessage.Text = "Welcome to Work Warriors";
            var credentials  = new NetworkCredential(name, pass);
            var transportWeb = new SendGrid.Web(credentials);

            transportWeb.DeliverAsync(myMessage);

            return(RedirectToAction("About", "Home"));
        }
Ejemplo n.º 14
0
        // Use NuGet to install SendGrid (Basic C# client lib)
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress(
                "*****@*****.**", "Talent Unleash");
            myMessage.Subject = message.Subject;
            myMessage.Text    = message.Body;
            myMessage.Html    = message.Body;

            var credentials = new NetworkCredential(
                ConfigurationManager.AppSettings["mailAccount"],
                ConfigurationManager.AppSettings["mailPassword"]
                );

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 15
0
        /*
        static string smtpAddress = "smtp.gmail.com";
        static int portNumber = 587;
        static bool enableSSL = true;
        static string emailFrom = "*****@*****.**";
        static string password = "******";
        //string emailTo = "*****@*****.**";
        static string subject = "";
        static string body = "";
        static string org;
        //*/
        /*
        public static void enviarAlerta(string emailTo, string subject,string body)
        {
            try
            {                

                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(emailFrom);
                    mail.To.Add(emailTo);
                    mail.Subject = subject;
                    mail.Body = body;
                    mail.IsBodyHtml = true;
                    // Can set to false, if you are sending pure text.

                    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                    {
                        smtp.Credentials = new NetworkCredential(emailFrom, password);
                        smtp.EnableSsl = enableSSL;
                        smtp.Send(mail);
                    }
                }
            }
            catch
            {
                
            }
        }
        //*/

        public static void enviarAlerta(List<string> emailTo, string subject, string body) 
        {
            // Add multiple addresses to the To field.
            List<String> recipients = emailTo;

            var username = System.Environment.GetEnvironmentVariable("SENDGRID_USERNAME");
            var pswd = System.Environment.GetEnvironmentVariable("SENDGRID_PASSWORD");

            // Create the email object first, then add the properties.
            SendGridMessage myMessage = new SendGridMessage();
            myMessage.AddTo(recipients);
            myMessage.From = new MailAddress("*****@*****.**", "Sistema de avisos Renta-Maq");
            myMessage.Subject = subject;
            myMessage.Html= body;

            // Create credentials, specifying your user name and password.
            var credentials = new NetworkCredential(username, pswd);

            // Create an Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email, which returns an awaitable task.
            transportWeb.DeliverAsync(myMessage);

            // If developing a Console Application, use the following
            // transportWeb.DeliverAsync(mail).Wait();
        }
Ejemplo n.º 16
0
 private void sendEmails(Dictionary<string, string> users)
 {
     if (users.Count < 1)
     {
         return;
     }
     var credentials = new NetworkCredential("*****@*****.**", "qYzcc6C3Z1A7TB2");
     var transportWeb = new Web(credentials);
     var myMessage = new SendGridMessage();
     myMessage.From = new MailAddress("*****@*****.**", "ExpInfo team");
     myMessage.Text = "Happy Birthday! Thanks for using our servises!";
     foreach (var user in users)
     {
         try
         {
             myMessage.AddTo(user.Value);
             myMessage.Subject = string.Format("Hello, {0}!", user.Key);
             // Send the email.
             transportWeb.Deliver(myMessage);
         }
         catch (Exception)
         {
         }
     }
 }
Ejemplo n.º 17
0
        public async  void SendMailNotification(string sharePointAppUrl, string name, string useremail = null)
        {
                string description = $"Sharepoint site '{name}' created.";
                var urlValue = "<a href=" + name + ">" + sharePointAppUrl + "</a>";

                object[] parameters = { description , urlValue };
                var msgBody = GetMailMessage(parameters);

                var mailMessage = new SendGridMessage();

                var mailFrom = WebConfigurationManager.AppSettings["MailFrom"];
                var maintenanceEmailAddress = WebConfigurationManager.AppSettings["MaintenanceEmailAddress"];
                var mailUserName = WebConfigurationManager.AppSettings["MailUserID"];
                var mailPassword = WebConfigurationManager.AppSettings["MailPassword"];

                mailMessage.From = new MailAddress(mailFrom);
                var recipients = new List<string> {maintenanceEmailAddress};

                if (useremail != null)
                {
                    recipients.Add(useremail);
                }

                recipients.Add(mailFrom);
                mailMessage.AddTo(recipients);

                mailMessage.Subject =  description; 
                mailMessage.Html = msgBody;

                var credentials = new NetworkCredential(mailUserName, mailPassword);
                var transportWeb = new Web(credentials);
                await transportWeb.DeliverAsync(mailMessage);
            

        }
Ejemplo n.º 18
0
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Francisco Paz");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            // Create network credentials to access your SendGrid account
            var username = "";
            var pswd = "";

            var credentials = new NetworkCredential(username, pswd);
            
            //var credentials = new NetworkCredential(ConfigurationManager.AppSettings["emailService:Account"],
            //                                        ConfigurationManager.AppSettings["emailService:Password"]);

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 19
0
        private async Task FeedbackEmailAsync(FeedbackViewModel message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo("*****@*****.**");
            myMessage.From = new System.Net.Mail.MailAddress(message.Email, message.Name);
            myMessage.Subject = message.Subject;
            myMessage.Html = message.Message;

            var transportWeb = new Web("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");

            try
            {
                if (transportWeb != null)
                {
                    await transportWeb.DeliverAsync(myMessage);
                }
                else
                {
                    await Task.FromResult(0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task<bool> SendMailAsync(MailMessage mm, bool suppressExceptions=true)
        {
            try
            {
                string userName = _configurationService.SendGridUsername;
                string password = _configurationService.SendGridPassword;

                var message = new SendGridMessage();

                message.From = new MailAddress(mm.From);
                message.AddTo(mm.To);
                message.Subject = mm.Subject;
                message.Text = mm.Body;

                var credentials = new NetworkCredential(userName, password);
                var transportWeb = new Web(credentials);
                await transportWeb.DeliverAsync(message).ConfigureAwait(false);

                return true;
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());

                if (!suppressExceptions)
                    throw;
            }

            return false;
        }
Ejemplo n.º 21
0
        private Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();
            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress(
                                "*****@*****.**", "Joe S.");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential(
                       ConfigurationManager.AppSettings["mailAccount"],
                       ConfigurationManager.AppSettings["mailPassword"]
                       );

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                return transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                return Task.FromResult(0);
            }
        }
Ejemplo n.º 22
0
        private async Task SendGridAsync(IdentityMessage message)
        {
            var sec = (ConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection);

            if (sec != null)
            {
                var displayName = sec.From;
                var fromEmailAddress = sec.Network.UserName;
                var passwordEmail = sec.Network.Password;

                var sendMessage = new SendGridMessage()
                {
                    From = new MailAddress(fromEmailAddress, displayName),
                    Subject = message.Subject,
                    Text = message.Body,
                    Html = message.Body
                };
                sendMessage.AddTo(message.Destination);

                var credentials = new NetworkCredential(fromEmailAddress, passwordEmail);
                var transportWeb = new Web(credentials);
                if (transportWeb != null)
                {
                    await transportWeb.DeliverAsync(sendMessage);
                }
                else
                {
                    await Task.FromResult(0);
                }
            }
            else
            {
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 23
0
        private async Task ConfigSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Система за гласуване.");
            myMessage.Subject = message.Subject;
            myMessage.Html = message.Body;

            var transportWeb = new Web("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");
            try
            {
                if (transportWeb != null)
                {
                    await transportWeb.DeliverAsync(myMessage);
                }
                else
                {
                    await Task.FromResult(0);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //reads in data and sends email
        public ActionResult SendEmailSubmit(int segment, string subject, string content)
        {
            int Segment = segment;
            //searches for desired customers and adds them to list
            var recipientList = new List <string>();

            foreach (var i in db.CustomerModels)
            {
                if (i.CampaignModelID == Segment)
                {
                    recipientList.Add(i.Email);
                }
            }
            var campaignEmail = new SendGrid.SendGridMessage();

            //new email
            campaignEmail.From = new MailAddress("*****@*****.**");
            //email account we will use
            campaignEmail.AddTo(recipientList);
            //adds recipients to be sent to
            campaignEmail.Subject = subject;
            //adds subject of the email
            campaignEmail.Text = content;
            //content of email is added
            var credential = new NetworkCredential("*****@*****.**", "Bretts@uto1");
            //email credentials we will use to send email
            var transportWeb = new Web(credential);

            transportWeb.DeliverAsync(campaignEmail);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 25
0
        public void Enviar(string nome, string email, string assunto, string mensagem)
        {
            var myMessage = new SendGridMessage();

            myMessage.From = new MailAddress(email, nome);
            myMessage.AddTo("*****@*****.**");
            myMessage.Subject = assunto;
            myMessage.Text = mensagem;

            var username = "******";
            var pswd = "20LTaus55pBSA3m";
            /* Alternatively, you may store these credentials via your Azure portal
               by clicking CONFIGURE and adding the key/value pairs under "app settings".
               Then, you may access them as follows:
               var username = System.Environment.GetEnvironmentVariable("SENDGRID_USER");
               var pswd = System.Environment.GetEnvironmentVariable("SENDGRID_PASS");
               assuming you named your keys SENDGRID_USER and SENDGRID_PASS */

            var credentials = new NetworkCredential(username, pswd);
            var transportWeb = new Web(credentials);

            // Send the email.
            // You can also use the **DeliverAsync** method, which returns an awaitable task.
            transportWeb.DeliverAsync(myMessage);
        }
        // POST: api/RequestData
        public HttpResponseMessage Post([FromBody]RequestData value)
        {
            try
            {
                // Create the email object first, then add the properties.
                SendGridMessage myMessage = new SendGridMessage();
                myMessage.AddTo("*****@*****.**");
                myMessage.From = new MailAddress("*****@*****.**");
                myMessage.Subject = string.Format("Message from DRB Technology");
                myMessage.Text = string.Format("From: {0} {1} \n Message: {2}", value.email, value.yourName, value.yourRequest);

                // Create credentials, specifying your user name and password.
                //TODO: Set credentials
                var credentials = new NetworkCredential("", "");

                // Create an Web transport for sending email, using credentials...
                var transportWeb = new Web(credentials);

                // ...OR create a Web transport, using API Key (preferred)
                //var transportWeb = new Web("This string is an API key");

                // Send the email.
                transportWeb.DeliverAsync(myMessage);
            }
            catch (Exception ex)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.InnerException);
            }

            return Request.CreateResponse(HttpStatusCode.OK, "Thank you for your request. We aim to respond within 24 hours.");
        }
Ejemplo n.º 27
0
        public void CreateMimeMessage()
        {
            var message = new SendGridMessage();
            var attachment = Path.GetTempFileName();
            var text = "this is a test";
            var html = "<b>This<\b> is a better test";
            var headers = new KeyValuePair<String, String>("custom", "header");
            message.AddAttachment(attachment);
            message.Text = text;
            message.Html = html;
            message.AddTo("*****@*****.**");
            message.From = new MailAddress("*****@*****.**");
            message.AddHeaders(new Dictionary<string, string> {{headers.Key, headers.Value}});
            message.EnableGravatar();

            var mime = message.CreateMimeMessage();

            var sr = new StreamReader(mime.AlternateViews[0].ContentStream);
            var result = sr.ReadToEnd();
            Assert.AreEqual(text, result);

            sr = new StreamReader(mime.AlternateViews[1].ContentStream);
            result = sr.ReadToEnd();
            Assert.AreEqual(html, result);

            result = mime.Headers.Get(headers.Key);
            Assert.AreEqual(headers.Value, result);

            result = mime.Headers.Get("X-Smtpapi");
            var expected = "{\"filters\" : {\"gravatar\" : {\"settings\" : {\"enable\" : \"1\"}}}}";
            Assert.AreEqual(expected, result);

            result = mime.Attachments[0].Name;
            Assert.AreEqual(Path.GetFileName(attachment), result);
        }
Ejemplo n.º 28
0
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();
            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress(
                                "*****@*****.**", "LaFactureria");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential(
                       ConfigurationManager.AppSettings["mailAccount"],
                       ConfigurationManager.AppSettings["mailPassword"]
                       );

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                Trace.TraceError("Fallo al crear el transporte Web y no se fue posible enviar el correo.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 29
0
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            //NEED TO UPDATE THIS TO OUR DETAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! http://bitoftech.net/2015/02/03/asp-net-identity-2-accounts-confirmation-password-user-policy-configuration/
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Taiseer Joudeh");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            //NEED TO UPDATE THIS TO OUR DETAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! http://bitoftech.net/2015/02/03/asp-net-identity-2-accounts-confirmation-password-user-policy-configuration/
            var credentials = new NetworkCredential(ConfigurationManager.AppSettings["emailService:Account"],
                                                    ConfigurationManager.AppSettings["emailService:Password"]);

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 30
0
        public static void SendPasswordResetEmail(string toEmail, string encodeUserID, string plainUserName)
        {
            try
            {
                var          domain      = HttpContext.Current.Request.Url.Authority;
                StreamReader reader      = new StreamReader(HttpContext.Current.Server.MapPath("/EmailTemplate/PasswordReset.html"));
                string       readFile    = reader.ReadToEnd();
                var          redirectUrl = ConfigurationManager.AppSettings["CurruntURL"].ToString() + "/#/resetPassword/" + encodeUserID;
                string       myString    = "";
                myString = readFile;
                myString = myString.Replace("{USERNAME}", plainUserName);
                myString = myString.Replace("{VERIFICATION_LINK}", redirectUrl);

                var myMessage = new SendGrid.SendGridMessage();
                myMessage.AddTo(toEmail);
                myMessage.From    = new MailAddress("*****@*****.**", "JobsInABA");
                myMessage.Subject = "Forgot Password";
                myMessage.Html    = myString.ToString();

                var transportWeb = new SendGrid.Web("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");
                transportWeb.DeliverAsync(myMessage);

                //// MailMessage class is present is System.Net.Mail namespace
                //MailMessage mailMessage = new MailMessage();
                //var _fromMailAddress = ConfigurationManager.AppSettings["FromMailAddress"].ToString();
                //var _fromMailPassword = ConfigurationManager.AppSettings["FromMailPassword"].ToString();
                //var _fromMailSMTP = ConfigurationManager.AppSettings["FromMailSMTP"].ToString();
                //int _formMailPort = Convert.ToInt32(ConfigurationManager.AppSettings["FromMailPort"]);

                //MailAddress fromMail = new MailAddress(_fromMailAddress);
                //mailMessage.From = fromMail;
                //mailMessage.To.Add(toEmail);
                //mailMessage.IsBodyHtml = true;
                //mailMessage.Body = myString.ToString();
                //mailMessage.Subject = "Forgot Password";

                //SmtpClient smtpClient = new SmtpClient(_fromMailSMTP, _formMailPort);
                //smtpClient.EnableSsl = Convert.ToBoolean(ConfigurationManager.AppSettings["IsEnableSSl"].ToString());
                //smtpClient.Credentials = new System.Net.NetworkCredential()
                //{
                //    UserName = _fromMailAddress,
                //    Password = _fromMailPassword
                //};

                //smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 31
0
 public static void SendMail(string Email, string subject, string body)
 {
     try
     {
         var myMessage = new SendGrid.SendGridMessage();
         myMessage.AddTo(Email);
         myMessage.From    = new MailAddress("*****@*****.**", "bePlus team");
         myMessage.Subject = subject;
         myMessage.Html    = body;
         //send mail;
         var transportWeb = new Web(new NetworkCredential("*****@*****.**", "Nagin420"));
         transportWeb.Deliver(myMessage);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Ejemplo n.º 32
0
        static void Main(string[] args)
        {
            Dictionary <string, string> users = new Dictionary <string, string>();

            users.Add("*****@*****.**", "Vadym Ivashyn");
            users.Add("*****@*****.**", "Second Vadym");


            var myMessage = new SendGrid.SendGridMessage();

            myMessage.From = new MailAddress("*****@*****.**", "Title");

            foreach (var u in users)
            {
                myMessage.AddTo(u.Key);
            }

            List <string> userNames = users.Values.ToList();

            myMessage.AddSubstitution("%user%", userNames);
            myMessage.AddSubstitution("%title%", new List <string> {
                "Hello from title"
            });
            myMessage.AddSubstitution("%body%", new List <string> {
                "Some text from body"
            });

            myMessage.EnableTemplateEngine("57ece6c2-b625-4bd6-92e7-2def1a3b0693");



            myMessage.Html = "Email content here";

            myMessage.Subject = "Email subject here";


            NetworkCredential nc = new NetworkCredential("*****@*****.**", "KPgZDZiM7c8hXHz");
            var transportWeb     = new SendGrid.Web(nc);

            transportWeb.DeliverAsync(myMessage).Wait();
            Console.WriteLine("Good");
            Console.ReadLine();
        }
Ejemplo n.º 33
0
        public async Task SendEmailGridAsync(string email, string subject, string msg)
        {
            var myMessage = new SendGrid.SendGridMessage();

            myMessage.AddTo(email);
            myMessage.From    = new System.Net.Mail.MailAddress("*****@*****.**", "David Silwal");
            myMessage.Subject = subject;
            myMessage.Text    = msg;

            var credentials = new System.Net.NetworkCredential(
                "DavidSilwal",
                "Admin123!@#");

            // Create a Web transport for sending email.
            var transportWeb = new SendGrid.Web(credentials);

            await transportWeb.DeliverAsync(myMessage);

            await Task.FromResult(0);
        }
Ejemplo n.º 34
0
        /**
         * This method will prepare the message by putting in information from the form.
         * and will send the message to a method SendAsync to check the credential of Sendgrid.
         * @param string to, string from, string fromName, string companyName, string phoneNum, string longMessage
         * @return void
         */
        private static void SendEmail(string to, string from, string fromName, string companyName, string phoneNum, string longMessage)
        {
            // Create the email object first, then add the properties.
            var myMessage = new SendGrid.SendGridMessage();

            myMessage.AddTo(to);
            myMessage.AddCc(from);
            myMessage.From    = new MailAddress(from, fromName);
            myMessage.Subject = "Email from ASP.NET Portfolio site";
            myMessage.Text    = " Message Detail \n" +
                                "From: " + fromName + "(" + from + ") \n" +
                                "Company: " + companyName + "\n" +
                                "Contact Number: " + phoneNum + "\n" +
                                "Message: " + longMessage;

            /* Example from sendgrid
             * var subs = new List<String> { "私は%type%ラーメンが大好き" };
             * myMessage.AddSubstitution("%tag%", subs);
             * myMessage.AddSection("%type%", "とんこつ");
             */

            SendAsync(myMessage);
        }
Ejemplo n.º 35
0
        private void SendEmailToAlertChange(string Sku, string Guid)
        {
            var firstName = "";
            var surName   = "";

            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("[dbo].[SPU_HT_Dashboard_Overview]"))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Variable", Guid);

                    command.Connection = connection;
                    connection.Open();
                    SqlDataReader myReader = command.ExecuteReader();
                    while (myReader.Read())
                    {
                        firstName = myReader["firstname"].ToString();
                        surName   = myReader["surname"].ToString();
                    }

                    connection.Close();
                }
            }

            var myMessage = new SendGrid.SendGridMessage();

            myMessage.AddTo("*****@*****.**");
            myMessage.From    = new MailAddress("*****@*****.**", "Hope Tools");
            myMessage.Subject = "An SKU has been edited in Hope.Tools";
            myMessage.Text    = "Product SKU:" + Sku + " Was modified by " + firstName + " " + surName + ", on " + DateTime.Now.ToString("M/d/yyyy") + " at " + DateTime.Now.ToString("h:mm:ss tt");
            var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridApi"].ToString());

            transportWeb.DeliverAsync(myMessage);
        }
Ejemplo n.º 36
0
        public static Task EnviaEmailAsync(IdentityMessage messagem)
        {
            // serviço para enviar email
            var minhaMensagem = new SendGrid.SendGridMessage();

            minhaMensagem.AddTo(messagem.Destination);
            minhaMensagem.From    = new System.Net.Mail.MailAddress("*****@*****.**", "Find");
            minhaMensagem.Subject = messagem.Subject;
            minhaMensagem.Text    = messagem.Body;
            minhaMensagem.Html    = messagem.Body;
            var credenciais = new NetworkCredential("FPBFDV", "paraiba2002");
            // Cria um transporte web para enviar email
            var transporteWeb = new Web(credenciais);

            // Envia o email
            if (transporteWeb != null)
            {
                return(transporteWeb.DeliverAsync(minhaMensagem));
            }
            else
            {
                return(Task.FromResult(0));
            }
        }
Ejemplo n.º 37
0
        public void Execute(IJobExecutionContext context)
        {
            db = new ApplicationDbContext();
            //var myMessage = new SendGrid.SendGridMessage();
            var requests     = db.ServiceRequests.ToList();
            var AcceptedList = db.HomeownerComfirmedBids.ToList();
            var completed    = db.CompletedBids.ToList();
            var conList      = db.ContractorAcceptedBids.ToList();

            string name = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt");
            string pass = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");

            foreach (var i in requests)
            {
                var myMessage = new SendGrid.SendGridMessage();
                if ((i.CompletionDeadline < DateTime.Now) && (i.expired == false))
                {
                    myMessage.AddTo(i.email);
                    myMessage.From    = new MailAddress("*****@*****.**", "Admin");
                    myMessage.Subject = "Your service request has expired!";
                    string message = "Hello " + i.Username + "," + "<br>" + "<br>" + "Your service request \"" + i.Description + "\" has expired because the completion deadline has passed.";
                    myMessage.Html = message;
                    var credentials  = new NetworkCredential(name, pass);
                    var transportWeb = new SendGrid.Web(credentials);
                    transportWeb.DeliverAsync(myMessage);
                    i.expired = true;
                    db.SaveChanges();
                }
            }

            foreach (var x in AcceptedList)
            {
                var myMessage = new SendGrid.SendGridMessage();
                if ((x.CompletionDeadline < DateTime.Now) && (x.expired == false))
                {
                    myMessage.AddTo(x.ConEmail);
                    myMessage.From    = new MailAddress("*****@*****.**", "Admin");
                    myMessage.Subject = "Completion deadline expired!";
                    string message = "Hello " + x.ConUsername + "," + "<br>" + "<br>" + "The deadline for completing the service request \"" + x.Description + "\" from \"" + x.HomeUsername + "\" has expired.";
                    myMessage.Html = message;
                    var credentials  = new NetworkCredential(name, pass);
                    var transportWeb = new SendGrid.Web(credentials);
                    transportWeb.DeliverAsync(myMessage);
                    x.expired = true;
                    db.SaveChanges();
                }
            }

            foreach (var i in completed)
            {
                if ((i.CompletionDeadline < DateTime.Now) && (i.Expired == false))
                {
                    i.Expired = true;
                    db.SaveChanges();
                }
            }

            foreach (var i in completed)
            {
                if ((i.CompletionDeadline < DateTime.Now) && (i.Expired == false))
                {
                    i.Expired = true;
                    db.SaveChanges();
                }
            }

            foreach (var i in conList)
            {
                if ((i.CompletionDeadline < DateTime.Now) && (i.expired == false))
                {
                    i.expired = true;
                    db.SaveChanges();
                }
            }
        }
Ejemplo n.º 38
0
        public void SendMinutesEmail(string date)
        {
            //sql call fetch data
            List <DetailsByHour> NotesList = new List <DetailsByHour>();

            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("SPU_HT_Reports_GetNotesAndDetailsForDateForSending"))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@Date", date);

                    command.Connection = connection;
                    connection.Open();
                    SqlDataReader myReader = command.ExecuteReader();
                    while (myReader.Read())
                    {
                        DetailsByHour NoteItem = new DetailsByHour();

                        NoteItem.Notes         = myReader["tvnotes"].ToString().Split('¬')[0];
                        NoteItem.DirectorNotes = myReader["tvnotes"].ToString().Split('¬')[1];
                        NoteItem.FloorNotes    = myReader["tvnotes"].ToString().Split('¬')[2];
                        NoteItem.GoingForward  = myReader["tvnotes"].ToString().Split('¬')[3];
                        NoteItem.ShowName      = myReader["tvnotesother"].ToString().Split('¬')[0];
                        NoteItem.Presenter     = myReader["Presenter"].ToString();
                        NoteItem.Producer      = myReader["Producer"].ToString();
                        NoteItem.Sales         = myReader["tvnotesother"].ToString().Split('¬')[3];
                        NoteItem.Director      = myReader["tvnotesother"].ToString().Split('¬')[4];
                        NoteItem.Floor         = myReader["tvnotesother"].ToString().Split('¬')[5];
                        NoteItem.Guest         = myReader["tvnotesother"].ToString().Split('¬')[6];
                        NoteItem.Hour          = myReader["showdatetime"].ToString().Split(' ')[1].Split(':')[0];

                        NotesList.Add(NoteItem);
                    }

                    connection.Close();
                }
            }
            //format data
            var emailHtml = "";

            foreach (DetailsByHour note in NotesList)
            {
                var propertime = getpropertime(note.Hour);
                emailHtml += "<table style=\"max-width:600px;\" width=\"100%\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" +
                             "<tbody><tr><td>" +
                             "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" +
                             "<tbody><tr>" +
                             "<td style=\"font-family:Gotham, Helvetica, Arial, sans-serif; font-size:30px; font-weight:bold; text-transform:uppercase; color:#ffffff; background: #058ca0; background-image: url('https://www.hochanda.com/Styles/Images/strip_texture10.png'); text-align: center; padding:5px;\"><a href=\"#\" style=\"color:#FFFFFF; text-decoration:none;\">" + propertime + " - " + note.ShowName + "</a></td>" +
                             "</tr><tr><td>&nbsp;</td></tr><tr><td>" +
                             "<table style=\"border-color: #ccc;border: 1px;\" width=\"300\" align=\"left\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\">" +
                             "<tbody><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px; font-weight: bold; text-transform: uppercase;    background-color: #f1f1f1;    width: 90px;\">Producer:</td>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.Producer + "</td>" +
                             "</tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px; font-weight: bold; text-transform: uppercase;    background-color: #f1f1f1;    width: 90px;\">Presenter:</td>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.Presenter + "</td>" +
                             "</tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px; font-weight: bold; text-transform: uppercase;    background-color: #f1f1f1;    width: 90px;\">Guest:</td>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.Guest + "</td>" +
                             "</tr></tbody></table>" +
                             "<table style=\"border-color: #ccc;border: 1px;\" width=\"300\" align=\"left\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\">" +
                             "<tbody><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px; font-weight: bold; text-transform: uppercase;    background-color: #f1f1f1;    width: 90px;\">Director:</td>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.Director + "</td>" +
                             "</tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px; font-weight: bold; text-transform: uppercase;    background-color: #f1f1f1;    width: 90px;\">Floor:</td>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.Floor + "</td>" +
                             "</tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px; font-weight: bold; text-transform: uppercase;    background-color: #f1f1f1;    width: 90px;\">Sales:</td>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:16px; line-height:16px; color:#ed137d; font-weight:bold;\">" + note.Sales + "</td>" +
                             "</tr></tbody></table></td></tr></tbody></table>" +
                             "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" +
                             "<tbody><tr><td>&nbsp;</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:30px; font-weight:bold; text-transform:uppercase; color:#ed137d; background: #f1f1f1; text-align: center;\">Summary</td>" +
                             "</tr><tr><td>&nbsp;</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:18px; font-weight:bold; text-transform:uppercase;\">Producer:</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.Notes + "</td>" +
                             "</tr><tr><td>&nbsp;</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:18px; font-weight:bold; text-transform:uppercase;\">Director:</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.DirectorNotes + "</td>" +
                             "</tr><tr><td>&nbsp;</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:18px; font-weight:bold; text-transform:uppercase;\">Floor Manager:</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.FloorNotes + "</td>" +
                             "</tr><tr><td>&nbsp;</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,  Helvetica, Arial, sans-serif; font-size:18px; font-weight:bold; text-transform:uppercase;\">Going Forward:</td></tr><tr>" +
                             "<td style=\"font-family:Gotham,   Helvetica, Arial, sans-serif; font-size:12px; line-height:16px;\">" + note.GoingForward + "</td>" +
                             "</tr><tr><td>&nbsp;</td></tr><tr>" +

                             "</tr></tbody></table></td></tr></tbody></table>";
            }

            var myMessage = new SendGrid.SendGridMessage();

            myMessage.AddTo(GetMinutesEmail());
            myMessage.From    = new MailAddress("*****@*****.**", "Hope Tools");
            myMessage.Subject = "Post Production Minutes ";
            myMessage.Html    = emailHtml;
            var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridApi"].ToString());

            transportWeb.DeliverAsync(myMessage);
        }
Ejemplo n.º 39
0
 public MailBuilder To(string email)
 {
     sendgrid.AddTo(email);
     return(this);
 }
Ejemplo n.º 40
0
        public ActionResult sendContractor(int id)
        {
            //if (this.User.IsInRole"conr"){

            //}
            //}
            string HomeEmail     = "";
            string HomeUserName  = "";
            string HomeFirstName = "";
            string HomeLastName  = "";
            string HomeAddress   = "";
            string HomeCity      = "";
            string HomeState     = "";
            string HomeZip       = "";
            int    Invoice       = 1;
            //string JobLocation = "";

            var    myMessage       = new SendGrid.SendGridMessage();
            string name            = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt");
            string pass            = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");
            var    contractors     = db.Contractors.ToList();
            var    homeowners      = db.Homeowners.ToList();
            var    servicerequests = db.ServiceRequests.ToList();
            var    acceptList      = db.ContractorAcceptedBids.ToList();
            var    confirmedList   = db.HomeownerComfirmedBids.ToList();
            string identity        = System.Web.HttpContext.Current.User.Identity.GetUserId();
            var    person          = db.Homeowners.Where(x => x.UserId == identity).SingleOrDefault();

            foreach (var user in db.Users)
            {
                if (user.Id == identity)
                {
                    HomeEmail = user.Email;
                    //username1 = user.UserName;
                    foreach (var home in homeowners)
                    {
                        if (home.email == HomeEmail)
                        {
                            HomeUserName  = home.Username;
                            HomeFirstName = home.FirstName;
                            HomeLastName  = home.LastName;
                            HomeAddress   = home.Address;
                            HomeCity      = home.City;
                            HomeState     = home.State;
                            HomeZip       = home.Zip;
                        }
                    }
                }
            }



            foreach (var i in acceptList)
            {
                if (id == i.ID)
                {
                    HomeownerComfirmedBids bid = new HomeownerComfirmedBids();
                    bid.ServiceRequestPaths = new List <ServiceRequestPath>();
                    bid.ConUsername         = i.ConUsername;
                    bid.HomeUsername        = i.HomeUsername;
                    bid.ConFirstName        = i.ConFirstName;
                    bid.HomeFirstname       = i.HomeFirstname;
                    bid.ConLastName         = i.ConLastName;
                    bid.HomeLastName        = i.HomeLastName;
                    bid.ConAddress          = i.ConAddress;
                    bid.HomeAddress         = i.HomeAddress;
                    bid.ConCity             = i.ConCity;
                    bid.HomeCity            = i.HomeCity;
                    bid.ConState            = i.ConState;
                    bid.HomeState           = i.HomeState;
                    bid.ConZip             = i.ConZip;
                    bid.HomeZip            = i.HomeZip;
                    bid.ConEmail           = i.ConEmail;
                    bid.HomeEmail          = i.HomeEmail;
                    bid.PostedDate         = i.PostedDate;
                    bid.CompletionDeadline = i.CompletionDeadline;
                    bid.Description        = i.Description;
                    bid.Bid            = i.Bid;
                    bid.Files          = i.Files;
                    bid.Service_Number = i.ServiceNumber;
                    foreach (var x in confirmedList)
                    {
                        if (x.Service_Number == bid.Service_Number)
                        {
                            return(RedirectToAction("Already_Confirmed", "HomeOwnerComfirmedBids"));
                        }
                    }
                    foreach (var z in servicerequests)
                    {
                        if (z.ServiceNumber == bid.Service_Number)
                        {
                            z.Confirmed = true;
                        }
                    }
                    foreach (var x in i.ServiceRequestPaths)
                    {
                        bid.ServiceRequestPaths.Add(new ServiceRequestPath()
                        {
                            FileName = x.FileName
                        });
                    }
                    bid.expired   = i.expired;
                    bid.Completed = false;
                    //bid.Service_Number = i.ServiceNumber;
                    bid.JobLocation = bid.HomeAddress + ", " + bid.HomeCity + ", " + bid.HomeState + " " + bid.HomeZip + ", " + "USA";
                    //foreach (var x in confirmedList)
                    //{
                    //    if (x.Service_Number == bid.Service_Number)
                    //    {
                    //        return RedirectToAction("Already_Confirmed", "HomeOwnerComfirmedBids");
                    //    }
                    //}
                    //foreach(var z in servicerequests)
                    //{
                    //    if(z.ServiceNumber == bid.Service_Number)
                    //    {
                    //        z.Confirmed = true;
                    //    }
                    //}
                    i.Confirmed   = true;
                    bid.Confirmed = true;
                    db.HomeownerComfirmedBids.Add(bid);
                    db.SaveChanges();
                    Invoice     = bid.ID;
                    bid.Invoice = Invoice;
                    myMessage.AddTo(i.ConEmail);
                    myMessage.From    = new MailAddress("*****@*****.**", "Admin");
                    myMessage.Subject = "Homeowner Confirmed Your Service!!";
                    string url  = "http://localhost:14703/HomeownerComfirmedBids/Confirm/" + Invoice;
                    string url2 = "http://localhost:14703/Maps/Calculate/" + Invoice;
                    //string message = "Job Location: <br>" + i.Address + "<br>" + i.City + "<br>" + i.State + "<br>" + i.Zip + "<br>" + "<br>" + "Job Description: <br>" + i.Description + "<br>" + "<br>" + "Bid price: <br>$" + i.Bid + "<br>" + "<br>" + "Must be completed by: <br>" + i.CompletionDeadline + "<br>" + "<br>" + "Date Posted: <br>" + i.PostedDate + "<br>" + "<br>" + "To accept job, click on link below: <br><a href =" + url + "> Click Here </a>";
                    String message = "Hello " + i.ConFirstName + "," + "<br>" + "<br>" + "Homeowner " + HomeUserName + " has confirmed your service for the following request:" + "<br>" + "<br>" + i.Description + "<br>" + "<br>" + "When the job is complete, please confirm completion by clicking on the link below: <br><a href =" + url + "> Click Here </a>" + "<br>" + "<br>" + "Get directions by clicking on the link below: <br><a href =" + url2 + "> Click Here </a>";
                    myMessage.Html = message;
                    var credentials  = new NetworkCredential(name, pass);
                    var transportWeb = new SendGrid.Web(credentials);
                    transportWeb.DeliverAsync(myMessage);
                }
                //i.posted = true;
                db.SaveChanges();
            }

            return(RedirectToAction("About", "Home"));
        }
Ejemplo n.º 41
0
        public ActionResult confirmCompletion(int id)
        {
            //if (this.User.IsInRole"conr"){

            //}
            //}
            string ConEmail     = "";
            string ConUserName  = "";
            string ConFirstName = "";
            string ConLastName  = "";
            string ConAddress   = "";
            string ConCity      = "";
            string ConState     = "";
            string ConZip       = "";
            int    Invoice      = 1;

            var    myMessage       = new SendGrid.SendGridMessage();
            string name            = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\name.txt");
            string pass            = System.IO.File.ReadAllText(@"C:\Users\erick\Desktop\Credentials\password.txt");
            var    contractors     = db.Contractors.ToList();
            var    homeowners      = db.Homeowners.ToList();
            var    servicerequests = db.ServiceRequests.ToList();
            var    acceptList      = db.ContractorAcceptedBids.ToList();
            var    confirmedList   = db.HomeownerComfirmedBids.ToList();
            var    completedList   = db.CompletedBids.ToList();
            string identity        = System.Web.HttpContext.Current.User.Identity.GetUserId();
            var    person          = db.Contractors.Where(x => x.UserId == identity).SingleOrDefault();

            foreach (var user in db.Users)
            {
                if (user.Id == identity)
                {
                    ConEmail = user.Email;
                    //username1 = user.UserName;
                    foreach (var con in contractors)
                    {
                        if (con.email == ConEmail)
                        {
                            ConUserName  = con.Username;
                            ConFirstName = con.FirstName;
                            ConLastName  = con.LastName;
                            ConAddress   = con.Address;
                            ConCity      = con.City;
                            ConState     = con.State;
                            ConZip       = con.Zip;
                        }
                    }
                }
            }



            foreach (var i in confirmedList)
            {
                if (id == i.ID)
                {
                    CompletedBids bid = new CompletedBids();
                    bid.ServiceRequestPaths = new List <ServiceRequestPath>();
                    bid.AfterPaths          = new List <AfterPath>();
                    bid.CompletedPaths      = new List <CompletedPath>();
                    bid.ConUsername         = i.ConUsername;
                    bid.HomeUsername        = i.HomeUsername;
                    bid.ConFirstName        = i.ConFirstName;
                    bid.HomeFirstname       = i.HomeFirstname;
                    bid.ConLastName         = i.ConLastName;
                    bid.HomeLastName        = i.HomeLastName;
                    bid.ConAddress          = i.ConAddress;
                    bid.HomeAddress         = i.HomeAddress;
                    bid.ConCity             = i.ConCity;
                    bid.HomeCity            = i.HomeCity;
                    bid.ConState            = i.ConState;
                    bid.HomeState           = i.HomeState;
                    bid.ConZip             = i.ConZip;
                    bid.HomeZip            = i.HomeZip;
                    bid.ConEmail           = i.ConEmail;
                    bid.HomeEmail          = i.HomeEmail;
                    bid.PostedDate         = i.PostedDate;
                    bid.CompletionDeadline = i.CompletionDeadline;
                    bid.Description        = i.Description;
                    bid.Bid            = i.Bid;
                    bid.Files          = i.Files;
                    bid.Service_Number = i.Service_Number;
                    foreach (var x in completedList)
                    {
                        if (x.Service_Number == bid.Service_Number)
                        {
                            return(RedirectToAction("Already_Confirmed_Completion", "CompletedBids"));
                        }
                    }
                    foreach (var x in i.ServiceRequestPaths)
                    {
                        bid.ServiceRequestPaths.Add(new ServiceRequestPath()
                        {
                            FileName = x.FileName
                        });
                    }
                    foreach (var x in i.AfterPaths)
                    {
                        bid.CompletedPaths.Add(new CompletedPath()
                        {
                            FileName = x.FileName
                        });
                    }
                    //bid.AfterPaths = i.AfterPaths;
                    //foreach (var x in i.AfterPaths)
                    //{


                    //    bid.AfterPaths.Add(new AfterPath() { FileName = x.FileName });
                    //    bid. = homeownerComfirmedBids.ID;

                    //}
                    //bid.Service_Number = i.Service_Number;
                    bid.ContractorDue  = i.Bid * .9m;
                    bid.ContractorPaid = false;
                    //foreach (var x in completedList)
                    //{
                    //    if (x.Service_Number == bid.Service_Number)
                    //    {
                    //        return RedirectToAction("Already_Confirmed_Completion", "CompletedBids");
                    //    }
                    //}

                    bid.Completed = true;
                    db.CompletedBids.Add(bid);
                    i.Completed = true;
                    db.SaveChanges();
                    Invoice     = bid.ID;
                    bid.Invoice = Invoice;
                    myMessage.AddTo(i.HomeEmail);
                    myMessage.From    = new MailAddress("*****@*****.**", "Admin");
                    myMessage.Subject = "Job Complete!!";
                    string url = "http://localhost:14703/CompletedBids/Payment/" + Invoice;
                    //string message = "Job Location: <br>" + i.Address + "<br>" + i.City + "<br>" + i.State + "<br>" + i.Zip + "<br>" + "<br>" + "Job Description: <br>" + i.Description + "<br>" + "<br>" + "Bid price: <br>$" + i.Bid + "<br>" + "<br>" + "Must be completed by: <br>" + i.CompletionDeadline + "<br>" + "<br>" + "Date Posted: <br>" + i.PostedDate + "<br>" + "<br>" + "To accept job, click on link below: <br><a href =" + url + "> Click Here </a>";
                    String message = "Hello " + i.HomeFirstname + "," + "<br>" + "<br>" + "Contractor " + ConUserName + " has completed your following service request:" + "<br>" + "<br>" + i.Description + "<br>" + "<br>" + "To complete payment, please click on link below: <br><a href =" + url + "> Click Here </a>";
                    myMessage.Html = message;
                    var credentials  = new NetworkCredential(name, pass);
                    var transportWeb = new SendGrid.Web(credentials);
                    transportWeb.DeliverAsync(myMessage);
                    conList.Add(ConEmail + i.ID);
                }
                //i.posted = true;
                db.SaveChanges();
            }

            return(RedirectToAction("About", "Home"));
        }
Ejemplo n.º 42
0
        public JsonResult GetMonitorAlerts(int FlexiUnder, int LablerRun, int PaymentAppRun, int PaymentAsRunRun, int flexiErrorCount, int labelerErrorCount, int paymentAppCount,
                                           int paymentAsPaidErrorCount, bool isMainMonitor, int potentialDuplicateOrderCount, int potentialDuplicateOrder)
        {
            MonitorErrorModel Error = new MonitorErrorModel {
                WasError          = 0, DidFlexiError = 0, DidLabelerError = 0, DidPaymentApp = 0, DidFreedomError = 0, DidPaymentAsPaidError = 0
                , FlexiErrorCount = flexiErrorCount, LabelerErrorCount = labelerErrorCount, PaymentAppCount = paymentAppCount, FreedomErrorCount = 0, PaymentAsPaidErrorCount = paymentAsPaidErrorCount
            };

            TimeSpan start = new TimeSpan(08, 00, 00); //8am o'clock
            TimeSpan end   = new TimeSpan(20, 00, 00); //8pm o'clock
            TimeSpan now   = DateTime.Now.TimeOfDay;

            if ((now > start) && (now < end))
            {
                if (potentialDuplicateOrderCount >= 1)
                {
                    //if (potentialDuplicateOrderCount > potentialDuplicateOrder)
                    //{
                    //    Error.WasError = 1;

                    //}
                    Error.NewDuplicateOrdersCount = potentialDuplicateOrderCount;
                    Error.DidDuplicateOrdersError = 1;
                }

                if (FlexiUnder >= 1)
                {
                    //Error.WasError = 1;
                    Error.DidFlexiError   = 1;
                    Error.FlexiErrorCount = flexiErrorCount + 1;
                }

                if (LablerRun > 80)
                {
                    Error.WasError          = 1;
                    Error.DidLabelerError   = 1;
                    Error.LabelerErrorCount = labelerErrorCount + 1;
                }

                if (PaymentAppRun > 90)
                {
                    Error.WasError        = 1;
                    Error.DidPaymentApp   = 1;
                    Error.PaymentAppCount = paymentAppCount + 1;
                }

                if (PaymentAsRunRun > 1)
                {
                    Error.WasError = 1;
                    Error.DidPaymentAsPaidError   = 1;
                    Error.PaymentAsPaidErrorCount = paymentAsPaidErrorCount + 1;
                }
            }
            else
            {
                if (FlexiUnder >= 1 && flexiErrorCount < 2 && isMainMonitor == true)
                {
                    var myMessage = new SendGrid.SendGridMessage();
                    myMessage.AddTo("*****@*****.**");
                    myMessage.From    = new MailAddress("*****@*****.**", "Hope Tools");
                    myMessage.Subject = "There has been an Error";
                    myMessage.Text    = "There have been flexibuy orders made and no records have been created for them in Payment_Schedule.";
                    var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridApi"].ToString());
                    transportWeb.DeliverAsync(myMessage);
                    Error.WasError        = 1;
                    Error.DidFlexiError   = 1;
                    Error.FlexiErrorCount = flexiErrorCount + 1;
                }

                if (LablerRun > 80 && labelerErrorCount < 2 && isMainMonitor == true)
                {
                    var myMessage = new SendGrid.SendGridMessage();
                    myMessage.AddTo("*****@*****.**");
                    myMessage.From    = new MailAddress("*****@*****.**", "Hope Tools");
                    myMessage.Subject = "There has been an Error";
                    myMessage.Text    = "The labeler has not run in over an hour and twenty Minutes.";
                    var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridApi"].ToString());
                    transportWeb.DeliverAsync(myMessage);
                    Error.WasError          = 1;
                    Error.DidLabelerError   = 1;
                    Error.LabelerErrorCount = labelerErrorCount + 1;
                }

                if (PaymentAppRun > 90 && paymentAppCount < 2 && isMainMonitor == true)
                {
                    var myMessage = new SendGrid.SendGridMessage();
                    myMessage.AddTo("*****@*****.**");
                    myMessage.From    = new MailAddress("*****@*****.**", "Hope Tools");
                    myMessage.Subject = "There has been an Error";
                    myMessage.Text    = "The payment app has not run in over an hour and a half.";
                    var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridApi"].ToString());
                    transportWeb.DeliverAsync(myMessage);
                    Error.WasError        = 1;
                    Error.DidPaymentApp   = 1;
                    Error.PaymentAppCount = paymentAppCount + 1;
                }

                if (PaymentAsRunRun > 1 && paymentAsPaidErrorCount < 2 && isMainMonitor == true)
                {
                    var myMessage = new SendGrid.SendGridMessage();
                    myMessage.AddTo("*****@*****.**");
                    myMessage.From    = new MailAddress("*****@*****.**", "Hope Tools");
                    myMessage.Subject = "There has been an Error";
                    myMessage.Text    = "The PaymentAsPaid SP has not been run.";
                    var transportWeb = new Web(ConfigurationManager.AppSettings["SendGridApi"].ToString());
                    transportWeb.DeliverAsync(myMessage);
                    Error.WasError = 1;
                    Error.DidPaymentAsPaidError   = 1;
                    Error.PaymentAsPaidErrorCount = paymentAsPaidErrorCount + 1;
                }
            }


            return(Json(Error, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 43
0
        public void SimpleEmail(string strTo, string strToEmail, string templateid, Hashtable hstemp, string subject)
        {
            try
            {
                // From
                string strFrom     = "*****@*****.**";
                string strFromName = "Arb bot";

                var myMessage = new SendGrid.SendGridMessage();
                myMessage.AddTo(strToEmail);
                myMessage.From    = new MailAddress(strFrom, strFromName);
                myMessage.Subject = subject;
                myMessage.Text    = " ";
                myMessage.Html    = " ";

                foreach (DictionaryEntry entry in hstemp)
                {
                    List <string> templist = new List <string>();
                    templist.Add(entry.Value.ToString());
                    myMessage.AddSubstitution(entry.Key.ToString(), templist);
                }

                //Filters
                var filters = new Dictionary <string, dynamic>()
                {
                    {
                        "opentrack", new Dictionary <string, dynamic>()
                        {
                            {
                                "settings", new Dictionary <string, dynamic>()
                                {
                                    {
                                        "enable", 1
                                    }
                                }
                            }
                        }
                    },
                    {
                        "templates", new Dictionary <string, dynamic>()
                        {
                            {
                                "settings", new Dictionary <string, dynamic>()
                                {
                                    {
                                        "enable", 1
                                    },
                                    {
                                        "template_id", templateid
                                    }
                                }
                            }
                        }
                    }
                };
                foreach (var filter in filters.Keys)
                {
                    var settings = filters[filter]["settings"];
                    foreach (var setting in settings.Keys)
                    {
                        myMessage.Header.AddFilterSetting(filter, new List <string> {
                            setting
                        }, Convert.ToString(settings[setting]));
                    }
                }

                /* CREDENTIALS
                 * ===================================================*/
                string sgUsername = ConfigurationSettings.AppSettings["Sendgrid_username"];
                string sgPassword = ConfigurationSettings.AppSettings["Sendgrid_pwd"];

                /* SEND THE MESSAGE
                 * ===================================================*/
                var credentials2 = new NetworkCredential(sgUsername, sgPassword);
                // Create a Web transport for sending email.
                var transportWeb = new Web(credentials2);

                // Send the email.
                transportWeb.Deliver(myMessage);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 44
-5
        public static void ConfirmRegistration(int registrationId, string reportpath)
        {
            var context = new CourseContext();
            var registration = context.Registrations.Include("Courses").FirstOrDefault(r => r.Id == registrationId);

            if (registration != null)
            {

                var myMessage = new SendGridMessage();
                myMessage.AddTo(registration.EMail);
                myMessage.AddTo("*****@*****.**");
                myMessage.From = new MailAddress("*****@*****.**", "Fahrschule Grütter-Stooss");
                var stream = new MemoryStream();
                var report = ReportHelper.GetReportFromFile(reportpath);
                report.ReportParameters["RegistrationId"].Value = registrationId;
                var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
                var renderingResult = reportProcessor.RenderReport("PDF", report, null);
                stream.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
                stream.Position = 0;
                myMessage.AddAttachment(stream, "Anmeldung.pdf");
                myMessage.Subject = "Bestätigung Deiner Anmeldung";

                if (registration.Courses.Count == 1)
                {
                    var course = registration.Courses.ElementAt(0);
                    myMessage.Text = string.Format("Für den Kurs {0} am {1}", course.Name, course.StartDateTime);
                }

                if (registration.Courses.Count > 1)
                {
                    var sb = new StringBuilder();
                    sb.AppendLine("Für die Kurse:");
                    foreach (var course in registration.Courses)
                    {
                        sb.AppendLine(string.Format("Für den Kurs {0} am {1}", course.Name, course.StartDateTime));

                        myMessage.Text = sb.ToString();
                    }
                }

                // Create credentials, specifying your user name and password.
                var credentials = new NetworkCredential("*****@*****.**",
                    "*****@*****.**");

                // Create an Web transport for sending email, using credentials...
                //var transportWeb = new Web(credentials);

                // ...OR create a Web transport, using API Key (preferred)
                var transportWeb = new Web("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");

                // Send the email.
                transportWeb.DeliverAsync(myMessage);
            }
        }
Ejemplo n.º 45
-5
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Thomas Watters");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential(ConfigurationManager.AppSettings["emailService:Account"],
                                                    ConfigurationManager.AppSettings["emailService:Password"]);

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 46
-6
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Taiseer Joudeh");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;

            var credentials = new NetworkCredential("",
                                                    "");

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
        public async Task SendAsync(IdentityMessage message)
        {
            // Create the email object first, then add the properties.
            var myMessage = new SendGridMessage();

            // this defines email and name of the sender
            myMessage.From = new MailAddress("*****@*****.**", "My Awesome Admin");

            // set where we are sending the email
            myMessage.AddTo(message.Destination);

            myMessage.Subject = message.Subject;

            // make sure all your messages are formatted as HTML
            myMessage.Html = message.Body;

            // Create credentials, specifying your SendGrid username and password.
            var credentials = new NetworkCredential("YourUsername", "YourPassword");

            // Create an Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            await transportWeb.DeliverAsync(myMessage);
        }
Ejemplo n.º 48
-10
        public void SendSMTP(string from, string to, string subject, string message, string cc = null, string bcc = null, string attachments = null, string alternateText = null, bool trackLinks = false)
        {
            SendGridMessage mailMessage = new SendGridMessage();
            MailAddress fromAddress = new MailAddress(from);


            List<string> recipients = to.Replace(",", ";").Split(';').ToList();
            
            mailMessage.From = fromAddress;
            mailMessage.AddTo(recipients);
            mailMessage.Subject = subject;
            mailMessage.Html = message;
            mailMessage.Text = alternateText;
            
            if(!String.IsNullOrEmpty(attachments))
            {
                List<string> attachmentFiles = attachments.Replace(",", ";").Split(';').ToList();
                foreach(string attachmentFile in attachmentFiles)
                {
                    mailMessage.AddAttachment(attachmentFile);
                }
            }

            mailMessage.EnableClickTracking(trackLinks);

            NetworkCredential credentials = new NetworkCredential(this._smtpUser, this._smtpPassword);
            var webTransport = new Web(credentials);

            webTransport.DeliverAsync(mailMessage).Wait();
        }
Ejemplo n.º 49
-11
        // Use NuGet to install SendGrid (Basic C# client lib) 
        private async Task configSendGridasync(IdentityMessage message)
        {
            var myMessage = new SendGridMessage();

            myMessage.AddTo(message.Destination);
            myMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Monsieur le développeur de Toyalist");
            myMessage.Subject = message.Subject;
            myMessage.Text = message.Body;
            myMessage.Html = message.Body;


            string sendGridAccount = ConfigurationManager.AppSettings["emailService:Account"];
            string sendGridPassword = ConfigurationManager.AppSettings["emailService:Password"];

            var credentials = new NetworkCredential(sendGridAccount, sendGridPassword);

            // Create a Web transport for sending email.
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                //Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }
        }
Ejemplo n.º 50
-15
        public bool Send()
        {
            
            


            // Create the email object first, then add the properties.
            var myMessage = new SendGridMessage {From = new MailAddress("*****@*****.**")};

            // Add the message properties.

            // Add multiple addresses to the To field.
            var recipients = new List<String>
            {
                @"W Thomas <*****@*****.**>",
                @"Will Thomas <*****@*****.**>"
            };

            myMessage.AddTo(recipients);

            myMessage.Subject = "Testing the SendGrid Library";

            //Add the HTML and Text bodies
            myMessage.Html = "<p>Hello World!</p>";
            myMessage.Text = "Hello World plain text!";

            // Create an Web transport for sending email.
            var transportWeb = new Web(_credentials);

            // Send the email.
            // You can also use the **DeliverAsync** method, which returns an awaitable task.
            transportWeb.Deliver(myMessage);
            return true;
        }
Ejemplo n.º 51
-19
        public void EmailReceipt(byte[] file, string fileName, OrderViewModel order)
        {
            // Set our SendGrid API User and Key values for authenticating our transport.
            var sendGridApiKey = "";
            var sendGridApiUser = "";

            // Create the email object first, and then add the properties.
            var myMessage = new SendGridMessage();

            // Add the message properties.
            myMessage.From = new MailAddress("*****@*****.**");

            // Add customer's email addresses to the To field.
            myMessage.AddTo(order.Email);

            myMessage.Subject = "Contoso Sports League order received";

            // Add the HTML and Text bodies.
            myMessage.Html = "";
            myMessage.Text = "";

            // Add our generated PDF receipt as an attachment.
            using (var stream = new MemoryStream(file))
            {
                myMessage.AddAttachment(stream, fileName);
            }

            var credentials = new NetworkCredential(sendGridApiUser, sendGridApiKey);
            // Create a Web transport using our SendGrid API user and key.
            var transportWeb = new Web(credentials);

            // Send the email.
            transportWeb.DeliverAsync(myMessage);
        }