Ejemplo n.º 1
0
        public static void SendNotificationNewTicket(Mail source)
        {
            try
            {
                SmtpClient smtpClient = new SmtpClient("kiininetcxp.com", 25)
                {
                    Credentials    = new System.Net.NetworkCredential("*****@*****.**", "SuppCalidad#.2019"),
                    DeliveryMethod = SmtpDeliveryMethod.Network
                };

                smtpClient.Send(Imap4Mail.ManagerMessage.SmtpMessage.CreateReplyNewTicket(source));

                //SmtpClient oSmtp = new SmtpClient();
                //SmtpServer server = GetServer();
                //if (server.ConnectType == SmtpConnectType.ConnectNormal)
                //{
                //    oSmtp.NativeSSLMode = false;
                //}
                //SmtpMail oMail = new SmtpMail("TryIt");
                //oMail.From = new MailAddress("*****@*****.**");
                //oMail.To.Add(new MailAddress("*****@*****.**"));
                //oMail.Subject = "first test email";
                //oMail.TextBody = "test body";

                //oSmtp.SendMail(server, oMail);
                //oSmtp.SendMail(server, Imap4Mail.ManagerMessage.NewMail.CreateReplyNewTicket(source));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
                public static MailMessage SenMailTicket(SmtpClient servidor, int idTicket, string clave, string body, string to)
                {
                    MailMessage reply = new MailMessage();

                    try
                    {
                        string references = reply.Headers.GetValues("References").ToString();

                        if (string.IsNullOrEmpty(references))
                        {
                            references += "~ticket&" + idTicket + "~";
                        }

                        reply.Headers.Add("References", references);
                        reply.From     = new MailAddress(servidor.Credentials.GetCredential(servidor.Host, servidor.Port, "").UserName);
                        reply.Subject += "Ticket " + idTicket;
                        reply.Subject  = reply.Subject.Replace("(Trial Version)", string.Empty).Trim();
                        reply.To.Add(to);
                        reply.IsBodyHtml = true;
                        reply.Body       = GeneraCorreoTicket(servidor.Credentials.GetCredential(servidor.Host, servidor.Port, "").UserName, "Kiininet", string.Empty, DateTime.Now.ToShortDateString().ToString(CultureInfo.InvariantCulture), idTicket, clave, body);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                    return(reply);
                }
Ejemplo n.º 3
0
        //Grek
        //public static void SendMail2(string from, string displayName, string to, List<MailAddress> bcc, List<MailAddress> cc, string subject, string body,
        //   string mailServer, string mailUsername, string mailPassword, int port, bool ssl = true, string attach = "")
        //{

        //    var builder = new BodyBuilder();
        //    MimeMessage mail = new MimeMessage();

        //    mail.From.Add(new MailboxAddress("", from));
        //    mail.To.Add(new MailboxAddress("", to.FirstOrDefault().Address));
        //    mail.Subject = "Mail Subject";
        //    builder.HtmlBody = "<html><body>Body Text";
        //    builder.HtmlBody += "</body></html>";
        //    mail.Body = builder.ToMessageBody();

        //    using (var client = new MailKit.Net.Smtp.SmtpClient())
        //    {
        //        client.Connect(mailServer, 465, true);
        //        client.AuthenticationMechanisms.Remove("XOAUTH2"); //' Do not use OAUTH2
        //        client.Authenticate(mailUsername, mailPassword); //' Use a username / password to authenticate.
        //        client.Send(mail);
        //        client.Disconnect(true);
        //    }
        //}
        //Grek


        // ненадежно
        public static void DirectMail()
        {
            EASendMail.SmtpMail   oMail = new EASendMail.SmtpMail("TryIt");
            EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();

            // Set sender email address, please change it to yours
            oMail.From = "*****@*****.**"; //[email protected]

            // Set recipient email address, please change it to yours
            oMail.To = "*****@*****.**";

            // Set email subject
            oMail.Subject = "direct email sent from c# project";

            // Set email body
            oMail.TextBody = "this is a test email sent from c# project directly";

            // Set SMTP server address to "".
            EASendMail.SmtpServer oServer = new EASendMail.SmtpServer("");

            // Do not set user authentication
            // Do not set SSL connection

            try
            {
                Console.WriteLine("start to send email directly ...");
                oSmtp.SendMail(oServer, oMail);
                Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
        }
Ejemplo n.º 4
0
 public static void SendNotificationTicketGenerated(int idTicket, string clave, string body, string to)
 {
     try
     {
         SmtpClient oSmtp = new SmtpClient();
         oSmtp.Send(Imap4Mail.ManagerMessage.NewMail.SenMailTicket(oSmtp, idTicket, clave, body, to));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 5
0
 public static void SendNotificationCommentTicket(Mail source)
 {
     try
     {
         SmtpClient oSmtp = new SmtpClient();
         oSmtp.Send(Imap4Mail.ManagerMessage.ResponseMail.CreateReplyComentarioTicket(source));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 6
0
        private static SmtpClient GetServer()
        {
            SmtpClient result;

            try
            {
                var    smtpSection = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp");
                string host        = smtpSection.Network.Host;
                int    port        = int.Parse(smtpSection.Network.TargetName);
                bool   ssl         = bool.Parse(ConfigurationManager.AppSettings["smtpSSL"]);
                string username    = smtpSection.Network.UserName;
                string pwd         = smtpSection.Network.Password;

                result = new SmtpClient("kiininetcxp.com", 25)
                {
                    Credentials    = new System.Net.NetworkCredential("*****@*****.**", "SuppCalidad#.2019"),
                    DeliveryMethod = SmtpDeliveryMethod.Network
                };

                //if (ssl)
                //{
                //    result = new SmtpServer(host)
                //    {
                //        Port = port,
                //        ConnectType = SmtpConnectType.ConnectSSLAuto,
                //        User = username,
                //        Password = pwd,

                //    };
                //}
                //else
                //{
                //    host = ConfigurationManager.AppSettings["smtp"];
                //    port = int.Parse(ConfigurationManager.AppSettings["smtpPort"]);

                //    result = new SmtpServer(host);
                //    result.ConnectType = SmtpConnectType.ConnectNormal;
                //    result.Port = port;
                //    result.User = username;
                //    result.Password = pwd;
                //}
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// this function will check weather a mail adress is valid or not
 /// </summary>
 /// <param name="email">the email to be checked</param>
 /// <returns>wether the email is a match or not</returns>
 public static Boolean TestMail(String email)
 {
     if (!CheckMailStructure(email))
     {
         return(false);
     }
     //first we set the mail smtp client
     EASendMail.SmtpMail   oMail   = new EASendMail.SmtpMail("TryIt");
     EASendMail.SmtpClient oSmtp   = new EASendMail.SmtpClient();
     EASendMail.SmtpServer oServer = new EASendMail.SmtpServer("");
     //then we set a generic sender
     oMail.From = "*****@*****.**";
     //and the mail we want to check vor validity
     oMail.To = email;
     try
     {
         oSmtp.TestRecipients(oServer, oMail);
         return(true);
     }
     catch
     {
         return(false);
     }
 }