コード例 #1
0
        public async Task <bool> SendUserStaffTerminationNotificationEmail(CustomerUserData user, int nroEmployeesTermination)
        {
            var pathToFile = _env.ContentRootPath + Path.DirectorySeparatorChar.ToString() + "Templates" + Path.DirectorySeparatorChar.ToString() + "Email"
                             + Path.DirectorySeparatorChar.ToString()
                             + "Emai_User_Staff_Termination_Notification_Layout.html";

            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile)) {
                builder.HtmlBody = SourceReader.ReadToEnd();
                SourceReader.Close();
            }

            var    url  = _ticketSettings.TicketDetailUrl;
            string body = string.Format(builder.HtmlBody,
                                        user.FirstName,           //{0}
                                        nroEmployeesTermination); //{1}

            EmailComponents email = new EmailComponents();

            email.Server = new Server()
            {
                Host = _emailSettings.EmailServerUrl,
                Port = _emailSettings.EmailServerPort
            };
            email.SenderEmail       = _emailSettings.ReceiverEmailApi;
            email.SenderEmailName   = _emailSettings.ReceiverEmailNameApi;
            email.ReceiverEmail     = user.Email;
            email.ReceiverEmailName = user.FirstName + " " + user.LastName;
            email.Subject           = _OTRSOptions.UserStaffTerminationNotification;
            email.Body = body;
            var sendEmail = await _senderEmailRepository.SendEmail(email);

            return(sendEmail);
        }
コード例 #2
0
        public async Task <bool> SendEmailCreateTicket(CustomerUserData user, string nroTicket)
        {
            var pathToFile = _env.ContentRootPath + Path.DirectorySeparatorChar.ToString() + "Templates" + Path.DirectorySeparatorChar.ToString() + "Email"
                             + Path.DirectorySeparatorChar.ToString()
                             + "Email_Create_Ticket_Layout.html";

            var builder = new BodyBuilder();

            using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile)) {
                builder.HtmlBody = SourceReader.ReadToEnd();
                SourceReader.Close();
            }

            var    url  = _ticketSettings.TicketDetailUrl + nroTicket;
            string body = string.Format(builder.HtmlBody,
                                        user.FirstName, //{0}
                                        nroTicket,      //{1}
                                        url);           //{2}

            EmailComponents email = new EmailComponents();

            email.Server = new Server()
            {
                Host = _emailSettings.EmailServerUrl,
                Port = _emailSettings.EmailServerPort
            };
            email.SenderEmail       = _emailSettings.ReceiverEmailApi;
            email.SenderEmailName   = _emailSettings.ReceiverEmailNameApi;
            email.ReceiverEmail     = user.Email;
            email.ReceiverEmailName = user.FirstName + " " + user.LastName;
            email.Subject           = _OTRSOptions.StoleAlertTicketEmailSubject + " " + nroTicket;
            email.Body = body;
            var sendEmail = await _senderEmailRepository.SendEmail(email);

            return(sendEmail);
        }