Exemplo n.º 1
0
        public static void setrequest(string body, string type)
        {
            List <BackServiceManager.TEST> objList = BackServiceManager.MailService();

            //new code with dynamic value
            foreach (BackServiceManager.TEST item in objList)
            {
                Generate_Notification gnr = new Generate_Notification();
                Generate_Notification.Notification_Log(Convert.ToInt32(item.CustomerID), body.ToString(), Convert.ToString(item.DeviceMacID), Convert.ToString(item.DeviceName), type);

                var fromAddress = new MailAddress("*****@*****.**");
                List <BackServiceManager.MailBring> listview = BackServiceManager.GetMail(item.DeviceMacID.ToString());
                foreach (BackServiceManager.MailBring list in listview)
                {
                    var          toAddress = new MailAddress(list.Mails); //[email protected]
                    const string subject   = "Server Viewer Mail Bildirim";
                    using (var smtp = new SmtpClient
                    {
                        Host = "mail.vodatech.com.tr",
                        Port = 587,
                        EnableSsl = false,
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials = new NetworkCredential(fromAddress.Address, "1qaz2wsxA")
                    })
                    {
                        using (var message = new MailMessage(fromAddress, toAddress)
                        {
                            Subject = subject, Body = body.ToString(), IsBodyHtml = true
                        })
                        {
                            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                            smtp.Send(message);
                        }
                    }
                }
            }
        }