09-27
This commit is contained in:
126
SubProject/FCM0000/Board/fSendMail.cs
Normal file
126
SubProject/FCM0000/Board/fSendMail.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using YARTE.UI.Buttons;
|
||||
using NetOffice;
|
||||
using Outlook = NetOffice.OutlookApi;
|
||||
using NetOffice.OutlookApi.Enums;
|
||||
|
||||
namespace FCM0000
|
||||
{
|
||||
public partial class fSendMail : FCOMMON.fBase
|
||||
{
|
||||
public fSendMail()
|
||||
{
|
||||
InitializeComponent();
|
||||
PredefinedButtonSets.SetupDefaultButtons(this.tbBody);
|
||||
this.dsMSSQL.MailData.TableNewRow += MailForm_TableNewRow;
|
||||
}
|
||||
|
||||
void MailForm_TableNewRow(object sender, DataTableNewRowEventArgs e)
|
||||
{
|
||||
e.Row["wuid"] = FCOMMON.info.Login.no;
|
||||
e.Row["wdate"] = DateTime.Now;
|
||||
e.Row["cate"] = "NR";
|
||||
}
|
||||
|
||||
private void fMailform_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.bs.AddNew();
|
||||
LoadNRData();
|
||||
}
|
||||
|
||||
void LoadNRData()
|
||||
{
|
||||
//자로에서 불러와서 그 값을 가져온다.
|
||||
dsMSSQLTableAdapters.MailFormTableAdapter taMF = new dsMSSQLTableAdapters.MailFormTableAdapter();
|
||||
var data = taMF.GetbyCate("NR");
|
||||
if (data != null && data.Rows.Count > 0)
|
||||
{
|
||||
var drForm = data.Rows[0] as dsMSSQL.MailFormRow;
|
||||
this.tbSubject.Text = drForm.subject;
|
||||
this.tbBody.Html = drForm.body;
|
||||
this.tbTo.Text = drForm.tolist;
|
||||
this.tbBCC.Text = drForm.bcc;
|
||||
this.tbCC.Text = drForm.cc;
|
||||
}
|
||||
}
|
||||
|
||||
private void mailFormBindingNavigatorSaveItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.Validate();
|
||||
|
||||
var drv = this.bs.Current as DataRowView;
|
||||
drv["body"] = this.tbBody.Html;
|
||||
drv.EndEdit();
|
||||
|
||||
this.bs.EndEdit();
|
||||
|
||||
this.tam.UpdateAll(this.dsMSSQL);
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
dsMSSQL.MailFormRow dr = null;
|
||||
private void bs_CurrentChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void richTextBox2_Validated(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void htmlEditor1_Validated(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void mailFormDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
var tolist = dr.tolist.Split(',');
|
||||
Outlook.Application outlookApplication = new Outlook.Application();
|
||||
foreach (var to in tolist)
|
||||
{
|
||||
if (to.isEmpty()) continue;
|
||||
var newMail = outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;
|
||||
newMail.Subject = this.tbSubject.Text.Trim(); // dr.title;
|
||||
newMail.To = to;
|
||||
newMail.CC = tbCC.Text.Trim();
|
||||
newMail.BCC = tbBCC.Text.Trim();
|
||||
newMail.HTMLBody = this.tbBody.Html
|
||||
.Replace("{USER}", FCOMMON.info.Login.nameK)
|
||||
.Replace("{EUSER}", FCOMMON.info.Login.nameE)
|
||||
.Replace("{EMAIL}", FCOMMON.info.Login.email)
|
||||
.Replace("%7BEMAIL%7D", FCOMMON.info.Login.email)
|
||||
.Replace("{HP}", FCOMMON.info.Login.hp)
|
||||
.Replace("{TEL}", FCOMMON.info.Login.tel)
|
||||
.Replace("{ITEM}", dr.title);
|
||||
|
||||
newMail.BodyFormat = OlBodyFormat.olFormatHTML;
|
||||
newMail.Display();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user