예제 #1
0
        // 发送邮件
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
                MessageBox.Show("不能含有空信息!");
            else
            {
                Email.Domain.Entities.MessageInbox messageinbox = new Email.Domain.Entities.MessageInbox();
                Email.Domain.Entities.MessageOutbox messageoutbox = new Email.Domain.Entities.MessageOutbox();
                Email.Data.MessageInboxData messageinboxdata = new Email.Data.MessageInboxData();
                Email.Data.MessageOutboxData messageoutboxdata = new Email.Data.MessageOutboxData();

                Email.Domain.Entities.Linkman linkman = new Email.Domain.Entities.Linkman();
                string[] arr = textBox1.Text.Split(';');
                int number = arr.Length;

                int num,  j, k = 0;
                string[] arr1 = new string[number];
                string string1 = "", string2 = "";
                for (num = 0; num < number; num++)
                {
                    IList<Email.Domain.Entities.Linkman> lm;
                    linkmandata = new Email.Data.LinkmanData();
                    lm = linkmandata.GetLinkmanByReceiver(UserHelper.uEmail, arr[num]);
                    if (lm.Count == 0)
                        string1 = string1 + arr[num] + ";";
                    else
                    {
                        string2 = string2 + arr[num] + ";";
                        arr1[k++] = arr[num];
                    }
                }

                messageinbox.Sender = messageoutbox.Sender = UserHelper.uEmail;
                messageinbox.Topic = messageoutbox.Topic = textBox2.Text;
                messageinbox.Content = messageoutbox.Content = "收件人:" + string2 + "\n" + textBox3.Text;

                if(string1 != null)
                    MessageBox.Show(string1 + "不是你的联系人,请于好友界面添加!");
                if(k != 0)
                {
                    for (j = 0; j < k; j++)
                    {
                        messageinbox.MessageinId = messageoutbox.MessageoutId = DateTime.Now.ToString();
                        messageinbox.Receiver = messageoutbox.Receiver = arr1[j];
                        messageoutboxdata.AddMessageOutbox(messageoutbox);
                        messageinboxdata.AddMessageInbox(messageinbox);
                    }
                    MessageBox.Show("已成功将邮件发送给" + string2 );
                }
            }
        }
예제 #2
0
파일: PIManager.cs 프로젝트: Janisac/Email
 //  注销账号
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox4.Text == "")
         MessageBox.Show("请输入密码");
     else
     {
         UserData userdata3 = new UserData();
         MessageOutboxData messageoutboxdata = new MessageOutboxData();
         MessageInboxData messageinboxdata = new MessageInboxData();
         LinkmanData linkmandata = new LinkmanData();
         User user = userdata3.GetUserByEmail(UserHelper.uEmail);
         if (textBox4.Text != user.PassWord)
         {
             MessageBox.Show("密码错误,请重新输入!");
             textBox4.Clear();
         }
         else
         {
             //User user = new User();
             //user.Email = UserHelper.uEmail;
             //user.PassWord = textBox4.Text;
             userdata3.DeleteUser(user);
             linkmandata.DeleteAllLinkman();
             messageinboxdata.DeleteAllMessageInbox();
             messageoutboxdata.DeleteAllMessageOutbox();
             //UserData userdata3 = new UserData();
             User user1 = userdata3.GetUserByEmail(UserHelper.uEmail);
             if (user1 == null & messageinboxdata.GetAllMessageInbox().Count == 0 & messageoutboxdata.GetAllMessageOutbox().Count == 0 & linkmandata.GetAllLinkman().Count == 0)
             {
                 MessageBox.Show("注销用户成功,并退出系统!");
                 textBox4.Clear();
                 this.Hide();
                 Logging logging = new Logging();
                 logging.Show();
             }
             else
                 MessageBox.Show("注销用户失败");
         }
     }
 }
예제 #3
0
파일: Linkman.cs 프로젝트: Janisac/Email
 // private System.Collections.IList clist;
 public Linkman()
 {
     InitializeComponent();
     linkmandata = new Email.Data.LinkmanData();
     dataGridView1.ReadOnly = true;
 }