Exemplo n.º 1
0
        /// <summary>
        /// メールサーバ情報取得
        /// </summary>
        private Hashtable GetMailServer()
        {
            DataSet ds = new DataSet();

            if (db.db.GetMailServer(0, 0, "编号,名称,地址,端口,用户,密码,送信人地址,服务器类型,添付文件,HTML", "", "", ref ds))
            {
                Hashtable ht = new Hashtable();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MailPara mp = new MailPara();
                    mp.name    = dr["名称"].ToString();
                    mp.address = dr["地址"].ToString();
                    //mp.port = dr["端口"].ToString();
                    mp.user           = dr["用户"].ToString();
                    mp.password       = dr["密码"].ToString();
                    mp.from           = dr["送信人地址"].ToString();
                    mp.servertype     = dr["服务器类型"].ToString().Trim();
                    mp.attachement    = dr["添付文件"].ToString();
                    mp.isHtml         = dr["HTML"].ToString();
                    ht[mp.servertype] = mp;
                }
                return(ht);
            }
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// メール送信
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            Hashtable ht = GetMailServer();
            MailPara  mp = (MailPara)ht["OUTLOOK"];

            mp.subject = txtTitle.Text;
            mp.body    = string.Format(txtContent.Text, lblConsultant.Text, txtDepartment.Text, txtManager.Text);
            mp.picfile = txtAttach.Text;
            mp.to      = txtMail.Text;
            if (mp.isHtml != "Y")
            {
                mp.htmlbody = null;
            }
            if (mp.attachement != "Y")
            {
                mp.picfile = null;
            }
            if (NCMail.SendEmail(mp.subject, mp.body, mp.htmlbody, mp.picfile, mp.address, mp.user, mp.password, mp.from, mp.to, mp.servertype))
            {
                MessageBox.Show("Mail Send Complete!");
                Close();
            }
            else
            {
                MessageBox.Show("Mail Send Fail!");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// workQueue_UserWork
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void workQueue_UserWork(object sender, WorkQueue <MailPara> .EnqueueEventArgs e)
        {
            MailPara mp = (MailPara)e.Item;

            setSend(mp.sendid, "送信中", mp.address);
            if (NCMail.SendEmail(mp.subject, mp.body, mp.htmlbody, mp.picfile, mp.address, mp.user, mp.password, mp.from, mp.to, mp.servertype))
            {
                setSend(mp.sendid, "送信完", mp.address);
            }
            else
            {
                setInvidMail(mp.to);
            }
            Thread.Sleep(15);
        }
Exemplo n.º 4
0
        /// <summary>
        /// getMailPara
        /// </summary>
        /// <param name="ht"></param>
        /// <param name="MailType"></param>
        /// <returns></returns>
        private MailPara getMailPara(Hashtable ht, string ServerType)
        {
            MailPara mp = new MailPara();

            if (ht[ServerType] != null)
            {
                mp.address     = ((MailPara)ht[ServerType]).address;
                mp.user        = ((MailPara)ht[ServerType]).user;
                mp.password    = ((MailPara)ht[ServerType]).password;
                mp.from        = ((MailPara)ht[ServerType]).from;
                mp.servertype  = ((MailPara)ht[ServerType]).servertype;
                mp.attachement = ((MailPara)ht[ServerType]).attachement;
                mp.isHtml      = ((MailPara)ht[ServerType]).isHtml;
            }
            return(mp);
        }
Exemplo n.º 5
0
        /// <summary>
        /// メール送信
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            Hashtable ht = GetMailServer();
            MailPara  mp = (MailPara)ht["OUTLOOK"];

            mp.subject = txtTitle.Text;
            bool result = true;

            for (int i = 0; i < data.Count; i++)
            {
                //lblConsultant.Text = data[1];
                //txtDepartment.Text = data[14];
                //txtManager.Text = data[2];
                //txtMail.Text = data[12];

                string[] items = (string[])data[i];
                mp.body    = string.Format(txtContent.Text, items[1], items[14], items[2]);
                mp.picfile = txtAttach.Text;
                mp.to      = items[12];
                if (mp.isHtml != "Y")
                {
                    mp.htmlbody = null;
                }
                if (mp.attachement != "Y")
                {
                    mp.picfile = null;
                }
                if (!NCMail.SendEmail(mp.subject, mp.body, mp.htmlbody, mp.picfile, mp.address, mp.user, mp.password, mp.from, mp.to, mp.servertype))
                {
                    result = false;
                }
            }
            if (result)
            {
                MessageBox.Show("Mail Send Complete!");
                Close();
            }
            else
            {
                MessageBox.Show("Mail Send Fail!");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// メール送信
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMailSend_Click(object sender, EventArgs e)
        {
            if (dgvData.SelectedRows.Count > 0)
            {
                string fileName = @"C:\temp\resume.xls";
                FileExport(fileName);
                string       membername = dgvData.SelectedRows[0].Cells[1].Value.ToString();
                FormCustomer form       = new FormCustomer(db);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    List <CustomerInfor> customerInfor = form.Customer;
                    Hashtable            mailserver    = GetMailServer();
                    if (mailserver != null)
                    {
                        foreach (CustomerInfor customer in customerInfor)
                        {
                            MailPara mp = (MailPara)mailserver["GMAIL"];
                            mp.to      = customer.mailaddress;
                            mp.subject = "人材紹介";
                            mp.body    = customer.companyname + "\r\n"
                                         + customer.name + " 様" + "\r\n"
                                         + membername + "を紹介します、よろしくお願いします。"
                            ;
                            mp.htmlbody = "";
                            mp.picfile  = fileName;
                            if (mp.isHtml != "Y")
                            {
                                mp.htmlbody = null;
                            }
                            if (mp.attachement != "Y")
                            {
                                mp.picfile = null;
                            }

                            NCMail.SendEmail(mp.subject, mp.body, mp.htmlbody, mp.picfile, mp.address, mp.user, mp.password, mp.from, mp.to, mp.servertype);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// getMailPara
 /// </summary>
 /// <param name="ds"></param>
 /// <param name="idx"></param>
 /// <param name="mp"></param>
 /// <returns></returns>
 private MailPara getMailPara(DataSet ds, int idx, MailPara mp)
 {
     mp.sendid  = ds.Tables[0].Rows[idx]["送信编号"].ToString();
     mp.to      = ds.Tables[0].Rows[idx]["mail"].ToString();
     mp.subject = ds.Tables[0].Rows[idx]["名称"].ToString()
                  + ds.Tables[0].Rows[idx]["发行期号"].ToString()
                  + "[" + ds.Tables[0].Rows[idx]["发行日期"].ToString() + "] By "
                  + mp.name;
     //mp.pdffile = ds.Tables[0].Rows[idx]["文件链接"].ToString();
     mp.body     = ds.Tables[0].Rows[idx]["文本内容"].ToString();
     mp.htmlbody = ds.Tables[0].Rows[idx]["邮件内容"].ToString();
     mp.picfile  = ds.Tables[0].Rows[idx]["图片链接"].ToString();
     if (mp.isHtml != "Y")
     {
         mp.htmlbody = null;
     }
     if (mp.attachement != "Y")
     {
         mp.picfile = null;
     }
     return(mp);
 }
Exemplo n.º 8
0
        /// <summary>
        /// 开始送信
        /// </summary>
        private void startSend()
        {
            WorkQueue <MailPara> workQueue_Outlook = new WorkQueue <MailPara>(5);

            workQueue_Outlook.UserWork      += new UserWorkEventHandler <MailPara>(workQueue_UserWork);
            workQueue_Outlook.WorkSequential = true;

            WorkQueue <MailPara> workQueue_HotMail = new WorkQueue <MailPara>(5);

            workQueue_HotMail.UserWork      += new UserWorkEventHandler <MailPara>(workQueue_UserWork);
            workQueue_HotMail.WorkSequential = true;

            WorkQueue <MailPara> workQueue_GMail = new WorkQueue <MailPara>(5);

            workQueue_GMail.UserWork      += new UserWorkEventHandler <MailPara>(workQueue_UserWork);
            workQueue_GMail.WorkSequential = true;

            WorkQueue <MailPara> workQueue_YMail = new WorkQueue <MailPara>(5);

            workQueue_YMail.UserWork      += new UserWorkEventHandler <MailPara>(workQueue_UserWork);
            workQueue_YMail.WorkSequential = true;

            WorkQueue <MailPara> workQueue_AMail = new WorkQueue <MailPara>(5);

            workQueue_AMail.UserWork      += new UserWorkEventHandler <MailPara>(workQueue_UserWork);
            workQueue_AMail.WorkSequential = true;

            ThreadPool.QueueUserWorkItem(o =>
            {
                DataSet ds_Server = new DataSet();
                if (db.GetMailServer(0, 0, "*", "", "", ref ds_Server) && ds_Server.Tables[0].Rows.Count > 0)
                {
                    Hashtable ht = new Hashtable();
                    foreach (DataRow dr in ds_Server.Tables[0].Rows)
                    {
                        MailPara mp = new MailPara();
                        mp.name     = dr["名称"].ToString();
                        mp.address  = dr["地址"].ToString();
                        //mp.port = dr["端口"].ToString();
                        mp.user           = dr["用户"].ToString();
                        mp.password       = dr["密码"].ToString();
                        mp.from           = dr["送信人地址"].ToString();
                        mp.servertype     = dr["服务器类型"].ToString().Trim();
                        mp.attachement    = dr["添付文件"].ToString();
                        mp.isHtml         = dr["HTML"].ToString();
                        ht[mp.servertype] = mp;
                    }
                    for (int ix = 0; ix < dataGridView1.SelectedRows.Count; ix++)
                    {
                        string ids = dataGridView1.SelectedRows[ix].Cells[0].Value.ToString();

                        DataSet ds      = new DataSet();
                        String strWhere = "送信编号=" + ids;
                        if (db.GetPublishVW(0, 0, "*", strWhere, "", ref ds))
                        {
                            int idx = 0;
                            while (idx < ds.Tables[0].Rows.Count)
                            {
                                if (workQueue_Outlook.getCount() < 5)
                                {
                                    MailPara mp = getMailPara(ht, "OUTLOOK");
                                    if (mp.servertype != null)
                                    {
                                        mp = getMailPara(ds, idx, mp);
                                        workQueue_Outlook.EnqueueItem(mp);
                                        idx++;
                                        if (idx >= ds.Tables[0].Rows.Count)
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (workQueue_HotMail.getCount() < 5)
                                {
                                    MailPara mp = getMailPara(ht, "HOTMAIL");
                                    if (mp.servertype != null)
                                    {
                                        mp = getMailPara(ds, idx, mp);
                                        workQueue_HotMail.EnqueueItem(mp);
                                        idx++;
                                        if (idx >= ds.Tables[0].Rows.Count)
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (workQueue_YMail.getCount() < 5)
                                {
                                    MailPara mp = getMailPara(ht, "YAHOO");
                                    if (mp.servertype != null)
                                    {
                                        mp = getMailPara(ds, idx, mp);
                                        workQueue_YMail.EnqueueItem(mp);
                                        idx++;
                                        if (idx >= ds.Tables[0].Rows.Count)
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (workQueue_GMail.getCount() < 5)
                                {
                                    MailPara mp = getMailPara(ht, "GMAIL");
                                    if (mp.servertype != null)
                                    {
                                        mp = getMailPara(ds, idx, mp);
                                        workQueue_GMail.EnqueueItem(mp);
                                        idx++;
                                        if (idx >= ds.Tables[0].Rows.Count)
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (workQueue_AMail.getCount() < 5)
                                {
                                    MailPara mp = getMailPara(ht, "AOL");
                                    if (mp.servertype != null)
                                    {
                                        mp = getMailPara(ds, idx, mp);
                                        workQueue_AMail.EnqueueItem(mp);
                                        idx++;
                                        if (idx >= ds.Tables[0].Rows.Count)
                                        {
                                            break;
                                        }
                                    }
                                }
                                Application.DoEvents();
                            }
                        }
                    }
                }
            });
        }