Ejemplo n.º 1
0
 public MailService(MailConfiguration mailConfiguration,
     Func<string, string> formatSubject, ILogger<MailService> logger)
 {
     _mailConfiguration = mailConfiguration;
     _formatSubject = formatSubject;
     _logger = logger;
 }
Ejemplo n.º 2
0
        public void Init()
        {
            var mc = new MailConfiguration(GmailConfiguration2);

            if (TestContext.TestName == "UsePickupFolderExample")
            {
                Directory.GetFiles(mc.PickupFolder).ToList().ForEach(File.Delete);
            }
        }
Ejemplo n.º 3
0
        public MailConfiguration GetConfiguration()
        {
            if (cachedMailConfiguration == null)
            {
                cachedMailConfiguration = JsonConvert.DeserializeObject <MailConfiguration>(new IOHelper(filePath).GetFileContent());
            }

            return(cachedMailConfiguration);
        }
        protected void btnChange_Click(object sender, EventArgs e)
        {
            User user = null;

            if (Global.User != null)
            {
                if (CheckRegEx(txtCPassword.Text.Trim()) || CheckRegEx(txtPassword.Text.Trim()))
                {
                    if (txtPassword.Text.Trim() == txtCPassword.Text.Trim())
                    {
                        if (Global.Core.Users.GetMD5Hash(txtOldPassword.Text.Trim()) == Global.User.Password)
                        {
                            if (Global.Core.Users.GetMD5Hash(txtOldPassword.Text.Trim()) == Global.Core.Users.GetMD5Hash(txtPassword.Text.Trim()))
                            {
                                Response.Redirect("ChangePassword.aspx?msg=4", false);
                            }
                            else
                            {
                                user          = Global.User;
                                user.Password = Global.Core.Users.GetMD5Hash(txtPassword.Text.Trim());
                                user.Browser  = Request.Browser.Browser;
                                user.Save();
                                // configuration values from the web.config file.
                                MailConfiguration mailConfiguration = new MailConfiguration(true);
                                // Create a new mail by the mail configuration.
                                Mail mail = new Mail(mailConfiguration, Global.Core.ClientName)
                                {
                                    TemplatePath = Path.Combine(Request.PhysicalApplicationPath,
                                                                "App_Data", "MailTemplates", Global.Language.ToString(), "PasswordChange.html"),
                                    Subject = "mail from Link online team"
                                };
                                mail.Placeholders.Add("imagepath", "http://" + Request.Url.ToString().Split('/')[2].ToString() + "/Images/Logos/link.png");
                                mail.Placeholders.Add("FirstName", user.FirstName);
                                mail.Placeholders.Add("LastName", user.LastName);
                                mail.Placeholders.Add("UserName", user.Name);
                                mail.Placeholders.Add("Password", txtPassword.Text.Trim());
                                mail.Placeholders.Add("clientsubdomain", "http://" + Request.Url.ToString().Split('/')[2].ToString());
                                mail.Send(user.Mail);
                                Response.Redirect("Home.aspx?msg=1", false);
                            }
                        }
                        else
                        {
                            Response.Redirect("ChangePassword.aspx?msg=3", false);
                        }
                    }
                    else
                    {
                        Response.Redirect("ChangePassword.aspx?msg=2", false);
                    }
                }
                else
                {
                    Response.Redirect("ChangePassword.aspx?msg=5", false);
                }
            }
        }
Ejemplo n.º 5
0
        protected void btnGo_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtMail.Text))
            {
                User user = null;
                if (Global.Core != null)
                {
                    // Check if the entered email is valid.
                    user = Global.Core.Users.GetSingle("Mail", txtMail.Text.Trim());
                    if (user != null)
                    {
                        //Global.User = user;
                        var pwdResetId = Guid.NewGuid();
                        user.SetValue("PasswordReset", pwdResetId);
                        user.SetValue("PwdCreated", DateTime.Now);
                        user.Save();

                        //string password = GeneratePassword(); //Membership.GeneratePassword(8, 2);

                        //user.Password = Global.Core.Users.GetMD5Hash(password);
                        //user.Browser = Request.Browser.Browser;
                        //user.Save();

                        // configuration values from the web.config file.
                        MailConfiguration mailConfiguration = new MailConfiguration(true);
                        // Create a new mail by the mail configuration.
                        Mail mail = new Mail(mailConfiguration, Global.Core.ClientName)
                        {
                            TemplatePath = Path.Combine(
                                Request.PhysicalApplicationPath,
                                "App_Data",
                                "MailTemplates",
                                Global.Language.ToString(),
                                "ForgotPassword.html"
                                ),
                            Subject = Global.LanguageManager.GetText("ForgotSubject")
                        };


                        string resetLink = "http://" + Request.Url.ToString().Split('/')[2] + "/Pages/ResetPassword.aspx?arb=" + pwdResetId;

                        // Add the placeholder value for the reset link.
                        mail.Placeholders.Add("imagepath", "http://" + Request.Url.ToString().Split('/')[2] + "/Images/Logos/link.png");
                        mail.Placeholders.Add("RequestURL", resetLink);
                        // Send the mail.
                        mail.Send(txtMail.Text.Trim());

                        Response.Redirect("PasswordAssistance.aspx?msg=1", false);
                    }
                    else
                    {
                        Response.Redirect("ForgotPassword.aspx?msg=2", false);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void LoadMailConfiguration()
        {
            MailConfigurationList = MailConfigurations.GetAll().ToSvenTechCollection();

            if (MailConfiguration == null)
            {
                MailConfiguration = new MailConfiguration();
            }
            Password = MailConfiguration.GetPasswordDecrypted();
        }
Ejemplo n.º 7
0
        public async Task SendMailAsync(MailConfiguration mailSettings, string message)
        {
            SmtpClient client = new SmtpClient(mailSettings.SmtpServer, mailSettings.SmtpServerPort);

            client.EnableSsl             = true;
            client.UseDefaultCredentials = false;
            client.Credentials           = new NetworkCredential(mailSettings.SmtpUser, mailSettings.SmtpPassword);

            MailMessage mailMessage = new MailMessage(mailSettings.Sender, mailSettings.Recipient, mailSettings.Subject, message);
            await client.SendMailAsync(mailMessage);
        }
Ejemplo n.º 8
0
        private static void RunMailSenderJob(string connectionString, int partitionId)
        {
            var serializer        = new Serializer();
            var executor          = new SqlProcedureExecutor(connectionString);
            var messages          = new EmailMessageRepository(executor);
            var mailConfiguration = new MailConfiguration();
            var sender            = new MailSender(mailConfiguration);

            var job = new MailSenderJob(messages, partitionId, sender, serializer);

            job.Work();
        }
Ejemplo n.º 9
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, MailConfiguration mail)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();
            app.UseDirectoryBrowser();
            app.UseStatusCodePages();
            app.UseMvc();
        }
Ejemplo n.º 10
0
        public MailConfigurationViewModel()
        {
            if (IsInDesignMode)
            {
                return;
            }

            SaveMailConfigCommand = new DelegateCommand(SaveMailConfiguration);
            SendTestMailCommand   = new DelegateCommand(SendTestMail);
            MailConfiguration     = new MailConfiguration();
            LoadMailConfiguration();
        }
Ejemplo n.º 11
0
 private void SaveMailConfiguration()
 {
     MailConfiguration.SetPassword(Password);
     if (MailConfiguration.MailConfigurationId == 0)
     {
         MailConfiguration.MailConfigurationId = MailConfigurations.Insert(MailConfiguration);
     }
     else
     {
         MailConfigurations.Update(MailConfiguration);
     }
 }
Ejemplo n.º 12
0
        protected void btnEmailAccept_Click(object sender, EventArgs e)
        {
            User user = null;

            if (Global.User != null)
            {
                if (txtOldEmail.Text.Trim() == Global.User.Mail.Trim())
                {
                    user = Global.User;

                    user.Mail    = txtOldEmail.Text.Trim();
                    user.Browser = Request.Browser.Browser;
                    user.Save();

                    // configuration values from the web.config file.
                    MailConfiguration mailConfiguration = new MailConfiguration(true);
                    // Create a new mail by the mail configuration.
                    Mail mail = new Mail(mailConfiguration, Global.Core.ClientName)
                    {
                        TemplatePath = Path.Combine(
                            Request.PhysicalApplicationPath,
                            "App_Data",
                            "MailTemplates",
                            Global.Language.ToString(),
                            "ContactChange.html"
                            ),
                        Subject = "mail from Link online team"
                    };
                    // Set the full path to the mail's template file.

                    // Add the placeholder value for the user's first name.

                    mail.Placeholders.Add("imagepath", "http://" + Request.Url.Host.ToString() + "/Images/Logos/link.png");
                    mail.Placeholders.Add("Message", "Your email has been changed for Link Online");
                    mail.Placeholders.Add("FirstName", user.FirstName);
                    mail.Placeholders.Add("LastName", user.LastName);
                    mail.Placeholders.Add("Email", user.Mail);
                    mail.Placeholders.Add("Phone", user.Phone);
                    mail.Placeholders.Add("clientsubdomain", "http://" + Request.Url.Host.ToString());

                    // Send the mail.
                    mail.Send(user.Mail);

                    Response.Redirect("Home.aspx?msg=5", false);
                }
                else
                {
                    Response.Redirect("Home.aspx?msg=6", false);
                }
            }
        }
Ejemplo n.º 13
0
        public EmailHelper(string configSource, EmailSettings settings)
        {
            if (string.IsNullOrWhiteSpace(configSource))
            {
                throw new ArgumentNullException(nameof(configSource));
            }

            Settings = settings ?? throw new ArgumentNullException(nameof(settings));

            var serializer = new XmlSerializer(typeof(MailConfiguration));

            using var fileStream = new FileStream(configSource, FileMode.Open);
            _mailConfiguration   = ((MailConfiguration)serializer.Deserialize(fileStream));
        }
Ejemplo n.º 14
0
 private void SendTestMail()
 {
     if (MailConfiguration.LoginUser != "" && MailConfiguration.Password != "" && MailConfiguration.Server != "")
     {
         MailConfiguration.SetPassword(Password);
         MailData mailData = new MailData
         {
             Body    = "Dies ist eine automatisch generierte Testmail.",
             Subject = "Testmail",
             To      = MailConfiguration.Address
         };
         Mail.Send(mailData, MailConfiguration);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Diese Methode wird zur Laufzeit aufgerufen. Kann benutzt werden, um Services zum Container hinzuzufügen.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            Serilog.Log.Debug("Konfiguriere die Services vom Webserver");

            var mailConfig = new MailConfiguration(
                this.Configuration["MailConfig:WarningMail:SmtpHostServer"],
                new NetworkCredential(this.Configuration["MailConfig:WarningMail:UserName"], this.Configuration["MailConfig:WarningMail:UserPassword"]))
            {
                SmtpServerPort = this.Configuration.GetValue <uint>("MailConfig:WarningMail:SmtpHostPort")
            };

            services.AddSingleton <MailConfiguration>(mailConfig);

            services.AddFluentMigratorCore();
            services.ConfigureRunner(migrationRunnerBuilder =>
            {
                //migrationRunnerBuilder.AddSQLite();
                //migrationRunnerBuilder.WithGlobalConnectionString("Data Source=test.db");
                migrationRunnerBuilder.AddMySql5();
                migrationRunnerBuilder.WithGlobalConnectionString(this.Configuration.GetConnectionString("HeaterDatabase"));
                migrationRunnerBuilder.ScanIn(typeof(Migrations._0000_Empty).Assembly).For.Migrations();
            });

            services.AddSingleton <IHeaterRepository>(new HeaterRepository(this.Configuration.GetConnectionString("HeaterDatabase")));
            services.AddSingleton <IHeaterDataService, HeaterDataService>();

            services.AddCors();

            services.AddControllers()
            .AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.Converters.Add(new StringEnumConverter());
            });
            services.AddSignalR();

            services.AddSwaggerGenNewtonsoftSupport();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Heizung.ServerDotNet", Version = "v1",
                });

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath, true);
            });

            Serilog.Log.Debug("Konfigurieren der Services vom Webserver abgeschlossen");
        }
Ejemplo n.º 16
0
        protected void Finalize(string fileName)
        {
            if (!this.SendMail)
            {
                return;
            }

            // Create a new mail configuration and load the
            // configuration values from the web.config file.
            MailConfiguration mailConfiguration = new MailConfiguration(true);

            // Create a new mail by the mail configuration.
            Mail mail = new Mail(mailConfiguration, this.Core.ClientName);

            // Set the full path to the mail's template file.
            mail.TemplatePath = Path.Combine(
                this.Request.PhysicalApplicationPath,
                "App_Data",
                "MailTemplates",
                this.Language,
                "LinkBiExportFinished.html"
                );

            // Add the placeholder value for the user's first name.
            mail.Placeholders.Add("FirstName", this.User.FirstName);

            // Add the placeholder value for the user's last name.
            mail.Placeholders.Add("LastName", this.User.LastName);

            mail.Placeholders.Add("imagepath", "http://" + Request.Url.Host.ToString() + "/Images/Logos/link.png");

            mail.Attachments.Add(
                "LinkBiExport.xls",
                File.ReadAllBytes(fileName)
                );

            try
            {
                // Send the mail.
                mail.Send(this.User.Mail);
            }
            catch (Exception ex)
            {
                /*base.ShowMessage(
                 *  string.Format(Global.LanguageManager.GetText("MailSendError"), Global.User.Mail, ex.Message),
                 *  WebUtilities.MessageType.Error
                 * );*/
            }
        }
Ejemplo n.º 17
0
 public UserController(
     ILogger <UserController> logger,
     RequestrContext dbContext,
     TokenService tokenService,
     BunqInitializer initializer,
     EmailService emailService,
     IOptions <MailConfiguration> mailConfig)
 {
     this.logger       = logger;
     this.dbContext    = dbContext;
     this.tokenService = tokenService;
     this.initializer  = initializer;
     this.emailService = emailService;
     this.mailConfig   = mailConfig.Value;
 }
Ejemplo n.º 18
0
        public async Task <ActionResult> Delete(int?id)
        {
            MailConfiguration mailConfiguration = await context.MailConfigurations.FindAsync(id);

            if (mailConfiguration == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            context.MailConfigurations.Remove(mailConfiguration);
            await context.SaveChangesAsync();

            //return Json(new AjaxResponse { Success = true, Message = "La Categoría se eliminó correctamente." }, JsonRequestBehavior.AllowGet);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 19
0
        public void Configure(out MailConfiguration mailConfiguration)
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("configs/appsettings.json")
                                .Build();
            var mailConfig = configuration.GetSection("mail");

            mailConfiguration = new MailConfiguration()
            {
                HostSmtp     = mailConfig.GetSection("hostSmtp").Value,
                LoginSmtp    = mailConfig.GetSection("loginSmtp").Value,
                MailFromSmtp = mailConfig.GetSection("mailFromSmtp").Value,
                PasswordSmtp = mailConfig.GetSection("passwordSmtp").Value,
                PortSmtp     = Convert.ToInt32(mailConfig.GetSection("portSmtp").Value),
                SslSmtp      = Convert.ToBoolean(mailConfig.GetSection("sslSmtp").Value)
            };
        }
Ejemplo n.º 20
0
        public MailSender([NotNull] MailConfiguration mailConfig)
        {
            if (mailConfig == null)
            {
                throw new ArgumentNullException(nameof(mailConfig));
            }
            try
            {
                Validator.ValidateObject(mailConfig, new ValidationContext(mailConfig), true);
            }
            catch (ValidationException)
            {
                throw new EmailConfigurationException("Email configuration is not correct");
            }

            this.MailConfiguration = mailConfig;
        }
Ejemplo n.º 21
0
        private IGraphServiceClient BuildGraphServiceClient()
        {
            this.mailConfiguration =
                this.configuration.Get <LocalConfiguration>()
                .MailConfiguration;

            IPublicClientApplication publicClientApplication =
                PublicClientApplicationBuilder
                .Create(this.mailConfiguration.ClientId)
                .WithTenantId(this.mailConfiguration.TenantId)
                .Build();

            var authProvider = new UsernamePasswordProvider(
                publicClientApplication,
                this.mailConfiguration.Scopes);

            return(new GraphServiceClient(authProvider));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Embed an image into an email message. In this sample the image is setup
        /// within this method but could have been passed in as a parameter.
        /// </summary>
        /// <param name="pConfig">appropriate <see cref="MailConfiguration"/> item</param>
        /// <param name="pSendToo">Valid email address to send message too</param>
        /// <param name="name">Represents who called this method</param>
        public void EmbedImageFromDisk(string pConfig, string pSendToo, [CallerMemberName] string name = "")
        {
            var mc   = new MailConfiguration(pConfig);
            var mail = new MailMessage
            {
                From    = new MailAddress(mc.FromAddress),
                Subject = $"Sent from test: '{name}'"
            };

            var plainMessage = AlternateView.CreateAlternateViewFromString(
                "This email desires html",
                null, "text/plain");

            /*
             *  This is the identifier for embeding an image into the email message.
             *  A variable is used because the identifier is needed into two areas,
             *  first in the AlternateView for HTML and secondly for the LinkedResource.
             */
            var imageIdentifier = "Miata";

            var htmlMessage = AlternateView.CreateAlternateViewFromString(
                $"<p>This is what I'm purchasing in <b>2019</b> to go along with my 2016 model.</p><img src=cid:{imageIdentifier}><p>Karen</p>",
                null, "text/html");

            var fileName   = $"{Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images1")}\\2017Miata.jpg";
            var miataImage = new LinkedResource(fileName, "image/jpeg")
            {
                ContentId = imageIdentifier
            };

            mail.AlternateViews.Add(plainMessage);
            mail.AlternateViews.Add(htmlMessage);
            htmlMessage.LinkedResources.Add(miataImage);

            mail.To.Add(pSendToo);
            mail.IsBodyHtml = true;

            using (var smtp = new SmtpClient(mc.Host, mc.Port))
            {
                smtp.Credentials = new NetworkCredential(mc.UserName, mc.Password);
                smtp.EnableSsl   = mc.EnableSsl;
                smtp.Send(mail);
            }
        }
Ejemplo n.º 23
0
        public void TestInitialize()
        {
            _context = new MockContainer();
            _context.SenderRepository.Setup(x => x.GetByUserId(TestConstants.TestAdminUserId)).Returns((long?)null);
            var configuration = new MailConfiguration();

            _sender     = new MailSender(configuration);
            _mailFolder = configuration.GetConfiguration(TestConstants.TestAdminUserId)
                          .SpecifiedPickupDirectory
                          .PickupDirectoryLocation;

            if (Directory.Exists(_mailFolder))
            {
                foreach (var file in Directory.EnumerateFiles(_mailFolder))
                {
                    File.Delete(file);
                }
            }
        }
Ejemplo n.º 24
0
        public void LoadMailAccountsFor(Employee theEmployee)
        {
            CheckTheObject(theEmployee);

            SqlCommand cmd = new SqlCommand();

            cmd.Parameters.Add(_EmployeeID, SqlDbType.Int).Value = theEmployee.Account.Id;
            using (SqlDataReader sdr = SqlHelper.ExecuteReader("GetEmployeeMailAccount", cmd))
            {
                while (sdr.Read())
                {
                    MailAccount mailAccount = new MailAccount(sdr[_DBLoginName].ToString(),
                                                              DalUtility.DecryptPassword(sdr[_DBPassword].ToString(), sdr[_DBLoginName].ToString()),
                                                              MailConfiguration.GetMailConfigurationById(int.Parse(sdr[_DBConfigurationId].ToString())));
                    mailAccount.Id = int.Parse(sdr[_DBPKID].ToString());
                    theEmployee.TheMailAccounts.Add(mailAccount);
                }
            }
        }
Ejemplo n.º 25
0
        public void SendContactMailService(ContactFormModel model, IPublishedContent receiver)
        {
            var recConfig = new MailConfiguration(receiver);

            var strBuilder = new StringBuilder();

            strBuilder.Append("<html>");
            strBuilder.Append("<head>");
            strBuilder.Append("</head>");
            strBuilder.Append("<body>");

            strBuilder.Append(recConfig.MailHeader);
            strBuilder.Append(recConfig.MailBody);
            strBuilder.Append($"<p>Name: {model.Name}<br />");
            strBuilder.Append($"Vorname: {model.FirstName}<br />");
            strBuilder.Append($"Adresse: {model.Address}<br />");
            strBuilder.Append($"PLZ/Ort: {model.ZipCity}<br />");
            strBuilder.Append($"Telefon: {model.Phone}<br />");
            strBuilder.Append($"Email: {model.Mail}<br />");
            strBuilder.Append($"Nachricht: {model.Message}<br /></p>");
            strBuilder.Append(recConfig.MailFooter);

            strBuilder.Append("</body>");
            strBuilder.Append("</html>");

            var sendMail = new MailMessage()
            {
                From       = new MailAddress(recConfig.SenderMail),
                Subject    = recConfig.MailSubject,
                Body       = strBuilder.ToString(),
                IsBodyHtml = true
            };

            string[] multipleMails = recConfig.ReceiverMail.Split(';');
            foreach (string tmpMails in multipleMails)
            {
                sendMail.To.Add(tmpMails);
            }


            SendMail(sendMail);
        }
Ejemplo n.º 26
0
        public static bool SendAccountConfirmationMail(string mailAddress, string accountNumber)
        {
            var mail = new MailMessage();

            mail.To.Add(mailAddress);

            mail.From = new MailAddress(MailConfiguration.MailAddress);

            mail.Subject = MailConfiguration.MailSubject;

            mail.Body = $"Thank you for creating account. <br/> Your account number is {accountNumber}";

            mail.IsBodyHtml = true;

            SmtpClient smtp = MailConfiguration.SetUpMailServer();

            smtp.Send(mail);

            return(true);
        }
Ejemplo n.º 27
0
        private static void SendServerOfflineNotification(Server server)
        {
            // configuration values from the web.config file.
            MailConfiguration mailConfiguration = new MailConfiguration(true);
            // Create a new mail by the mail configuration.
            Mail mail = new Mail(mailConfiguration, "_NONE_")
            {
                TemplatePath = Path.Combine(
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                    "ServerOfflineNotification.html"
                    ),
                Subject = "SERVER OFFLINE"
            };

            mail.Placeholders.Add("ServerIp", server.IP);
            mail.Placeholders.Add("Server", server.Description);

            // Send the mail.
            mail.Send(ConfigurationManager.AppSettings["ServerOfflineNotificationReciepent"]);
        }
Ejemplo n.º 28
0
 public AccountController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ISmsSender smsSender,
     ILoggerFactory loggerFactory,
     IOptions <MailConfiguration> mailConfig,
     IPlayerService eventService,
     IUserService userService)
     : base(userService)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _emailSender   = emailSender;
     _smsSender     = smsSender;
     _logger        = loggerFactory.CreateLogger <AccountController>();
     _mailConfig    = mailConfig.Value;
     _eventService  = eventService;
     _userService   = userService;
 }
Ejemplo n.º 29
0
        public void SendConfirmationMailService(ContactFormModel model, IPublishedContent customer)
        {
            var custConfig = new MailConfiguration(customer);

            var strBuilder = new StringBuilder();

            strBuilder.Append("<html>");
            strBuilder.Append("<head>");
            strBuilder.Append("</head>");
            strBuilder.Append("<body>");

            strBuilder.Append(custConfig.MailHeader);
            strBuilder.Append(custConfig.MailBody);
            strBuilder.Append($"<p>Name: {model.Name}<br />");
            strBuilder.Append($"Vorname: {model.FirstName}<br />");
            strBuilder.Append($"Adresse: {model.Address}<br />");
            strBuilder.Append($"PLZ/Ort: {model.ZipCity}<br />");
            strBuilder.Append($"Telefon: {model.Phone}<br />");
            strBuilder.Append($"Email: {model.Mail}<br />");
            strBuilder.Append($"Nachricht: {model.Message}<br /></p>");
            strBuilder.Append(custConfig.MailFooter);


            strBuilder.Append("</body>");
            strBuilder.Append("</html>");


            var sendMail = new MailMessage()
            {
                From       = new MailAddress(custConfig.SenderMail),
                Subject    = custConfig.MailSubject,
                Body       = strBuilder.ToString(),
                IsBodyHtml = true
            };

            sendMail.To.Add(model.Mail);



            SendMail(sendMail);
        }
Ejemplo n.º 30
0
        public ActionResult Details(int?id)
        {
            var conf = new MailConfiguration();

            if (id.HasValue)
            {
                conf = DocumentSession.Load <MailConfiguration>(id);

                if (conf == null)
                {
                    return(HttpNotFound());
                }
            }

            conf.Recipients = new List <string>()
            {
                string.Join(",", conf.Recipients)
            };

            return(View(conf));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 给员工发送邮件
        /// </summary>
        /// <param name="account">发件人账号</param>
        /// <param name="password">发件人密码</param>
        /// <param name="name">收件人姓名</param>
        /// <param name="content">收件内容-HTML格式</param>
        /// <param name="mailType">邮件类型:年假?调休</param>
        public void MailSending(string account, string password, string userAddress, string content, string mailType)
        {
            MailConfiguration config = new MailConfiguration();

            var    client  = config.GetMailClient(account, password);
            string subject = mailType.Equals("annual") ? _holidaySubject :
                             mailType.Equals("transfer") ? _transferSubject : "未知主题";
            //添加抄送对象
            string ccConfig = ConfigurationManager.AppSettings["holidayTransferMailCCObject"];

            string[] cc      = ccConfig.IndexOf(",") > 0 ? ccConfig.Split(',') : null;
            var      message = config.GetMailMessage(subject, account, content, cc == null ? null : cc.ToList());
            //配置收件人地址
            var address = config.GetMailAddress(userAddress);

            foreach (var mail in address)
            {
                message.To.Add(mail);
            }
            client.Send(message);
        }