/// <summary> /// 期刊发行测试,将期刊内容发给测试用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTest_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { DataSet ds = new DataSet(); String wheresql = "subscripted='T'"; if (db.GetCustomer(0, 0, "*", wheresql, "", ref ds)) { DataSet ds_Server = new DataSet(); if (db.GetMailServer(0, 0, "*", "", "", ref ds_Server) && ds_Server.Tables[0].Rows.Count > 0) { Random rdm = new Random(); foreach (DataRow dr in ds.Tables[0].Rows) { int idx = rdm.Next(0, ds_Server.Tables[0].Rows.Count - 1); String name = ds_Server.Tables[0].Rows[idx]["名称"].ToString(); String address = ds_Server.Tables[0].Rows[idx]["地址"].ToString(); String port = ds_Server.Tables[0].Rows[idx]["端口"].ToString(); String user = ds_Server.Tables[0].Rows[idx]["用户"].ToString(); String password = ds_Server.Tables[0].Rows[idx]["密码"].ToString(); String from = ds_Server.Tables[0].Rows[idx]["送信人地址"].ToString(); String attachement = ds_Server.Tables[0].Rows[idx]["添付文件"].ToString(); String isHtml = ds_Server.Tables[0].Rows[idx]["HTML"].ToString(); String servertype = ds_Server.Tables[0].Rows[idx]["服务器类型"].ToString().Trim(); String to = dr["mail"].ToString(); String pdffile = txtFileLink.Text; String body = txtText.Text; String picfile = txtPicLocal.Text; String htmlbody = txtMail.Text; if (isHtml != "Y") { htmlbody = null; } if (attachement != "Y") { picfile = null; } String subject = MagName + txtPublish.Text + "[" + txtDate.Text + "] By " + name; NCMail.SendEmail(subject, body, htmlbody, picfile, address, user, password, from, to, servertype); } } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0078I", db.Language); MessageBox.Show(msg); } } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0079I", db.Language); MessageBox.Show(msg); } } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0069I", db.Language); MessageBox.Show(msg); } }
/// <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!"); } }
/// <summary> /// 邮件服务器测试 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTest_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { String name = txtName.Text; String address = txtAddress.Text; String port = txtPort.Text; String user = txtUser.Text; String password = txtPassword.Text; String from = txtSender.Text; String servertype = cmbType.Text.Trim(); String attachement = cmbAttachment.Text.Trim(); String isHtml = cmbISHtml.Text.Trim(); String to = txtTestTo.Text; NdnPublicFunction function = new NdnPublicFunction(); if (!function.IsMail(to, false)) { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0066I", db.Language); MessageBox.Show(msg); return; } String subject = "这是测试" + " by " + name; String pdffile = "http://www.chojogakuin.com/weekly/20130907.pdf"; String body = "测试内容\r\n收到邮件说明测试成功\r\nURL=" + pdffile; String htmlbody = "<html><head></head><body>测试内容<br>收到邮件说明测试成功</body></html>"; String picfile = @"c:\test.jpg"; if (isHtml != "Y") { htmlbody = null; } if (attachement != "Y") { picfile = null; } if (NCMail.SendEmail(subject, body, htmlbody, picfile, address, user, password, from, to, servertype)) { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0067I", db.Language); MessageBox.Show(msg); } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0068I", db.Language); MessageBox.Show(msg); } } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0059I", db.Language); MessageBox.Show(msg); } }
/// <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); }
/// <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!"); } }
/// <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); } } } } }
/// <summary> /// 发送许可 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSend_Click(object sender, EventArgs e) { DataSet ds_Server = new DataSet(); if (db.GetMailServer(0, 0, "*", "", "", ref ds_Server) && ds_Server.Tables[0].Rows.Count > 0) { String name = ds_Server.Tables[0].Rows[0]["名称"].ToString(); String address = ds_Server.Tables[0].Rows[0]["地址"].ToString(); String port = ds_Server.Tables[0].Rows[0]["端口"].ToString(); String user = ds_Server.Tables[0].Rows[0]["用户"].ToString(); String password = ds_Server.Tables[0].Rows[0]["密码"].ToString(); String from = ds_Server.Tables[0].Rows[0]["送信人地址"].ToString(); String servertype = ds_Server.Tables[0].Rows[0]["服务器类型"].ToString().Trim(); String to = "*****@*****.**"; String body = "My Product:" + cmbProduct.Text; body += "My Product ID:" + txtProductID.Text; String picfile = ""; String htmlbody = "<html><head></head><body>" + body + "</body></html>"; String subject = "I wan't a license for CJW!"; if (NCMail.SendEmail(subject, body, htmlbody, picfile, address, user, password, from, to, servertype)) { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0108I", db.Language); MessageBox.Show(msg); } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0107I", db.Language); MessageBox.Show(msg); } } else { string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0107I", db.Language); MessageBox.Show(msg); } }