// public void Send_textWithCC(string to,string subject,string textMail,string textCCMailAddress ) // { // // } public void Send_text(string to, string subject, string textMail) { try { ma1 = new Mapi(); ma1.AddRecip(to, null, false); /* * if( textCC.Text != null ) * { * if( textCC.Text.Length > 0 ) * ma.AddRecip( textCC.Text, null, true ); * } */ //lblStatus.Text="Current Status : Sending Message"; if (!ma1.Send(subject, textMail)) { MessageBox.Show(this, "MAPISendMail failed! " + ma1.Error(), "Send Mail", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ma1.Reset(); //this.Close(); } catch (Exception exp) { MessageBox.Show(exp.Message.ToString()); } }
private void buttonSend_Click(object sender, System.EventArgs e) { //string htmltext = editor1.Html.ToString(); //System.IO.File.WriteAllText(@"C:\Users\HP\Desktop\htmltext.txt", htmltext); if (sendNum != 0) { if ((textTO.Text == null) || (textSubject.Text == null)) { return; } if ((textTO.Text.Length == 0) || (textSubject.Text.Length == 0)) { return; } Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients; Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(textTO.Text); if (textCC.Text != null) { if (textCC.Text.Length > 0) { Outlook.Recipients ccRecips = (Outlook.Recipients)oMsg.Recipients; Outlook.Recipient ccRecip = (Outlook.Recipient)ccRecips.Add(textTO.Text); ccRecip.Type = (int)Outlook.OlMailRecipientType.olCC; } //ma.AddRecip(textCC.Text, null, true); } oMsg.Subject = textSubject.Text; oMsg.HTMLBody = editor1.Html; //if (!ma.Send(textSubject.Text, textMail.Text)) // MessageBox.Show(this, "MAPISendMail failed! " + ma.Error(), "Send Mail", MessageBoxButtons.OK, MessageBoxIcon.Warning); oRecip.Resolve(); // Send. oMsg.Send(); // Log off. oNS.Logoff(); // Clean up. oRecip = null; oRecips = null; oMsg = null; oNS = null; oApp = null; ma.Reset(); this.Close(); } }
/// <summary> /// Send SimpleMAPI email /// </summary> public void SendMapi(string exceptionReport, IntPtr windowHandle) { var mapi = new Mapi(); mapi.Logon(windowHandle); mapi.Reset(); var emailAddress = string.IsNullOrEmpty(_reportInfo.EmailReportAddress) ? _reportInfo.ContactEmail : _reportInfo.EmailReportAddress; mapi.AddRecipient(emailAddress, null, false); AttachMapiScreenshotIfRequired(mapi); mapi.Send(EmailSubject, exceptionReport, true); mapi.Logoff(); }
public SendForm(ref Mapi rma, string filename, string thumbnailPath) { ma = rma; // // Required for Windows Form Designer support // InitializeComponent(); this.filename = filename; this.filename = filename.Replace("/", "\\"); ma.Reset(); this.lblComPath.Text = filename; this.AttachPic.Image = Image.FromFile(thumbnailPath); //int n = this.comboAttachm.Items.Add(filename); //comboAttachm.SelectedIndex = n; }
private void buttonSend_Click(object sender, System.EventArgs e) { ma.Attach(this.filename); lblStatus.Text = "Current Status : Adding Recipients"; ma.AddRecip(textTO.Text, null, false); if (textCC.Text != null) { if (textCC.Text.Length > 0) { ma.AddRecip(textCC.Text, null, true); } } lblStatus.Text = "Current Status : Sending Message"; if (!ma.Send(textSubject.Text, textMail.Text)) { MessageBox.Show(this, "MAPISendMail failed! " + ma.Error(), "Send Mail", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ma.Reset(); this.Close(); }
public SendForm(Form callingForm, ref Mapi rma) { ma = rma; oNS = oApp.GetNamespace("mapi"); oNS.Logon(Missing.Value, Missing.Value, true, true); oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem); preForm = callingForm as Form3; ma.Reset(); InitializeComponent(); Form1.unitTB[] unitsTB = preForm.returnUnitTB(); Form1.unitInfo[] unitInfos = preForm.returnUnitInfo(); if (preForm.returnChoose() == 1) { //textTO.Text = "Lee, Simon <*****@*****.**>; Hsu, Aurora <*****@*****.**>; HUNG, SEAN (Sean Hung) <*****@*****.**>; Tsai, Hunter <*****@*****.**>; Hsieh, David (David Hsieh) <*****@*****.**>; Chou, Cindy <*****@*****.**>; Cheng, Steven <*****@*****.**>; Su, Demi <*****@*****.**>; Chen, Frank (COMMs TDC) <*****@*****.**>; Su, YJ <*****@*****.**>; Lee, Connant <*****@*****.**>; Tseng, YJ <*****@*****.**>; Wu, Jason <*****@*****.**>; Lin, Robin ((COMM TDC)) <*****@*****.**>; Yang, Daniel (Comm TDC) <*****@*****.**>; Chen, Pat <*****@*****.**>; Lin, CF <*****@*****.**>; Chen, Troy (CMIT NB RandD) <*****@*****.**>; Hung, KC <*****@*****.**>; Lu, Jacky <*****@*****.**>; Chiang, Bernice <*****@*****.**>; Chan, Tony (WWAN) <*****@*****.**>; Lee, Amanda <*****@*****.**>; Chan, Tony (WWAN) <*****@*****.**>; Chien, Jeremy (Comms Radio HW) <*****@*****.**>; Chou, Emily (CMIT) <*****@*****.**>; Wu, Kent <*****@*****.**>; Chen, Xinchang (Comm TDC) <*****@*****.**>; Ma, Terry <*****@*****.**>; Lin, Steve <*****@*****.**>; Wu, Anthony <*****@*****.**>; Chou, Emily (CMIT) <*****@*****.**>; Cheng, Timothy <*****@*****.**>; Liu, Bruce <*****@*****.**>; Huang, Jake <*****@*****.**>; Tung, Grace <*****@*****.**>; Kuo, Jason <*****@*****.**>; You, Ethan (Comm TDC) <*****@*****.**>; Zeng, Grey <*****@*****.**>; Fong, Agness <*****@*****.**>; Liu, Sean (Comm TDC) <*****@*****.**>; Yu, Debby <*****@*****.**>; Hsieh, Sean <*****@*****.**>; Hsieh, James <*****@*****.**>; Lin, Tony <*****@*****.**>; Tsai, David <*****@*****.**>; Cheng, Mike <*****@*****.**>; Chu, Jimmy <*****@*****.**>"; //textCC.Text = "Chang, Hans <*****@*****.**>; Hung, KC <*****@*****.**>; Cheng, Steven <*****@*****.**>"; textSubject.Text = "Machines arrived "; Array.Clear(ph, 0, ph.Length); //if (ph.Length != 0) //{ // Array.Resize(ref ph, 0); //} bool phExist = false; for (int j = 0; j < unitsTB.Length; j++) { for (int i = 0; i < ph.Length; i++) { if (unitsTB[j].platform == ph[i]) { phExist = true; } } if (phExist == false) { Array.Resize(ref ph, ph.Length + 1); ph[ph.Length - 1] = unitsTB[j].platform; } phExist = false; } for (int i = 0; i < ph.Length; i++) { if (ph[i] != null) { textSubject.Text += "【" + ph[i] + "】"; } } sHtml += num1_start; createTable("CNB"); createTable("BNB"); createTable("CDT"); createTable("BDT"); createTable("CAIO"); createTable("BAIO"); sHtml += num1_endMail; } else { textSubject.Text = "IUR record update"; sHtml = num2_start + num1_type_open; if (unitInfos[0].Borrower == "Storage" || unitInfos[0].Borrower == "storage") { sHtml += "Return list"; } else { sHtml += "Borrow list"; } sHtml += num1_type_close + num2_table_open; for (int i = 0; i < unitInfos.Length; i++) { sHtml += num2_rowOpen1 + (i + 1).ToString() + "\">" + num2_rowOpen2 + unitInfos[i].Platform.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].Phase.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].SKU.ToString() + num2_rowClose + num2_rowOpen2_col4 + unitInfos[i].SN.ToString() + num2_rowClose + num2_rowOpen2_col5 + unitInfos[i].Borrower.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].Status.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].Year.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].Category.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].Note.ToString() + num2_rowClose + num2_rowOpen2 + unitInfos[i].Date.Substring(0, 10).ToString() + num2_rowClose + "</TR>"; } sHtml += "</TBODY></TABLE></SPAN></P>" + num1_endMail; //string htmltext = editor1.Html.ToString(); //System.IO.File.WriteAllText(@"C:\Users\HP\Desktop\htmltext.txt", htmltext); } editor1.Html = sHtml; //System.IO.File.WriteAllText(@"C:\Users\HP\Desktop\htmltext.txt", editor1.Html); }