Ejemplo n.º 1
0
        public static EmailTemplateModel BuildForInvitation(UserInformation user, CompanyInformation company, string link, string reciver)
        {
            var emailTemplate = new EmailTemplateModel();

            try
            {
                var body = string.Format(
                    "<table><tbody>" +
                    "<tr><td>Title</td><td>{0}</td></tr>" +
                    "<tr><td>Description</td><td>{1}</td></tr>" +
                    "<tr><td>Registration Link</td><td>{2}</td></tr>" +
                    "</tbody></table>", user.Name + "  " + user.SurName + " invites you for working in " + company.Name, "If you have some questions please write your employer :" + user.Email,
                    "To accept invitation pls follow this link an register : " + link);
                emailTemplate.Reciver = reciver;
                emailTemplate.Body    = body;
                emailTemplate.Subject = "Invitation for WorkFlow time tracking system";
            }
            catch (Exception ex)
            {
                var a = ex.Message;
                throw;
            }

            return(emailTemplate);
        }
Ejemplo n.º 2
0
        private static async Task <bool> SendEmail(EmailTemplateModel emailTemplate)
        {
            try
            {
                var client = new SmtpClient(_smtpHost, _smtpPort)
                {
                    Credentials = new NetworkCredential(_user, _password),
                    EnableSsl   = true
                };


                MailMessage message     = new MailMessage();
                MailAddress fromAddress = new MailAddress(_userEmail, "WorkFlow System");
                message.From       = fromAddress;
                message.Subject    = emailTemplate.Subject;
                message.IsBodyHtml = true;
                message.Body       = emailTemplate.Body;
                message.To.Add(emailTemplate.Reciver);
                await client.SendMailAsync(message);

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }