onlyou13

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
        private void button2_Click(object sender, EventArgs e)
        {
            // gmail -> qq
            SmtpClient MailClient = new SmtpClient();

            MailClient.Host = "smtp.gmail.com";
            MailClient.Port = 587;
            MailClient.Credentials = new NetworkCredential("gmail_zhanghao", "password");

            MailClient.EnableSsl = true;

            MailMessage Email = new MailMessage();
            Email.From = new MailAddress("gmail_zhanghao@gmail.com");           
            Email.Subject = "Subject test";
            Email.Body = "Body content";
            Email.IsBodyHtml = false;

            Email.To.Add("dest@qq.com");


            Attachment EmailAttachment = new Attachment(@"C:\log.zip");
            Email.Attachments.Add(EmailAttachment);

            MailClient.Send(Email);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            // qq -> gmail
            SmtpClient MailClient = new SmtpClient();

            MailClient.Host = "smtp.qq.com";
            MailClient.Port = 587;
            MailClient.Credentials = new NetworkCredential("qqqq@qq.com", "password");

            MailClient.EnableSsl = true;

            MailMessage Email = new MailMessage();
            Email.From = new MailAddress("qqqq@qq.com");
            Email.Subject = "Subject test";
            Email.Body = "Body content";
            Email.IsBodyHtml = false;

            Email.To.Add("dest@gmail.com");


            Attachment EmailAttachment = new Attachment(@"C:\log.zip");
            Email.Attachments.Add(EmailAttachment);

            MailClient.Send(Email);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            // hotmail -> gmail
            SmtpClient MailClient = new SmtpClient();

            MailClient.Host = "smtp.live.com";
            MailClient.Port = 587;
            MailClient.Credentials = new NetworkCredential("src@hotmail.com", "password");

            MailClient.EnableSsl = true;

            MailMessage Email = new MailMessage();
            Email.From = new MailAddress("src@hotmail.com");
            Email.Subject = "Subject test";
            Email.Body = "Body content";
            Email.IsBodyHtml = false;

            Email.To.Add("dest@gmail.com");


            Attachment EmailAttachment = new Attachment(@"C:\log.zip");
            Email.Attachments.Add(EmailAttachment);

            MailClient.Send(Email);
        }

 

posted on 2017-12-12 17:30  onlyou13  阅读(152)  评论(0编辑  收藏  举报