public static MapiAlloc FromString(string value, Encoding encoding = null) { if (encoding == null) { encoding = Encoding.Unicode; } byte[] data = encoding.GetBytes(value); byte[] term = encoding.GetBytes(new char[] { (char)0 }); // Allocate the buffer int size = data.Length + term.Length; IntPtr ptr = IntPtr.Zero; IntPtr res = MAPI.MAPIAllocateBuffer((uint)size, ref ptr); if (res != IntPtr.Zero) { throw new InvalidOperationException("MAPI Allocation failed: " + res); } // Zero it Kernel32.ZeroMemory(ptr, size); // And copy the data Marshal.Copy(data, 0, ptr, data.Length); return(new MapiAlloc(ptr)); }
private void btnSend_Click(object sender, EventArgs e) { string to = txtEmail.Text; string subject = txtSubject.Text; string body = txtMessage.Text; MAPI mapi = new MAPI(); foreach (string filename in mAttachments) { mapi.AddAttachment(filename); } mapi.AddRecipientTo(to); string error; mapi.SendMailPopup(subject, body, out error); if (!error.Equals("")) { MessageBox.Show(error); DialogResult = DialogResult.None; return; } DialogResult = DialogResult.OK; }
public void Launch(Form parentForm, ProjectInfo projectInfo) { string dest = Path.Combine(Path.GetTempPath(), projectInfo.Name + "_wesay.zip"); BackupMaker.BackupToExternal(projectInfo.PathToTopLevelDirectory, dest, projectInfo.FilesBelongingToProject); MAPI msg = new MAPI(); msg.AddAttachment(dest); msg.AddRecipientTo(_settings.Email); subject = String.Format( StringCatalog.Get("{0} WeSay Project Data", "The subject line of the email send by the 'Send Email' Action. The {0} will be replaced by the name of the project, as in 'Greek WeSay Project Data'"), projectInfo.Name); string body = StringCatalog.Get("The latest WeSay project data is attached."); //I tried hard to get this to run in a thread so it wouldn't block wesay, //but when called in a thread we always just get the generic '2' back. // EmailMessage emailWorker = // new EmailMessage( // subject, // body, // msg); ///emailWorker.SendMail(); /// msg.SendMailPopup(subject, body); }
public void TestSendEmail() { MAPI x = new MAPI(); x.AddRecipientTo("*****@*****.**"); x.SendMailDirect("test", "testbody"); }
private void SendMailPopup() { var regex = new Regex(@"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@" + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]? [0-9]{1,2}|25[0-5]|2[0-4][0-9])\." + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]? [0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|" + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$"); string subject; if (!String.IsNullOrEmpty(textBoxEmail.Text) && regex.IsMatch(textBoxEmail.Text)) { subject = string.Format("{0} {1} Crash Report by {2}", _appTitle, _appVersion, textBoxEmail.Text); } else { subject = string.Format("{0} {1} Crash Report", _appTitle, _appVersion); } var mapi = new MAPI(); mapi.AddRecipientTo(_toAddress.Address); if (File.Exists(string.Format("{0}\\{1}CrashScreenshot.png", Path.GetTempPath(), _appTitle)) && checkBoxIncludeScreenshot.Checked) { mapi.AddAttachment(string.Format("{0}\\{1}CrashScreenshot.png", Path.GetTempPath(), _appTitle)); } mapi.SendMailPopup(subject, HtmlReport()); }
private void toolButtonEmail_Click(object sender, EventArgs e) { MAPI mapi = new MAPI(); mapi.AddAttachment(mSelectedVoiceMailEntry.FullPath); mapi.SendMailPopup("FW: Voicemail from " + mSelectedVoiceMailEntry.Info.From, "FW: Voicemail from " + mSelectedVoiceMailEntry.Info.From); }
private void emailToolStripMenuItem_Click(object sender, EventArgs e) { frmEMail frm = new frmEMail(); frm.ShowDialog(); string stEMail = frm.GetEMail(); if (frm.DialogResult == DialogResult.Cancel) { return; } if (File.Exists("c:\\send.jpg")) { File.Delete("c:\\send.jpg"); } File.Copy(m_ImageFilePath, "c:\\send.jpg"); MAPI mapi = new MAPI(); // mapi.AddAttachment(m_ImageFilePath); mapi.AddAttachment("c:\\send.jpg"); mapi.AddRecipientTo(stEMail); mapi.SendMailPopup("My Subject", "body text"); }
private void sendToMailMenuItem6_Click(object sender, EventArgs e) { if (_fileName.Length >= 1) { var mapi = new MAPI(); mapi.AddAttachment(_fileName); mapi.SendMailPopup(string.Empty, _fileName); } }
//################################################################################################ // PDF Export public void Export_PDF() { try { // MessageBox.Show(sDirPDF); // Path of the selected Eplan project sProject = Get_Project(); if (sProject == "") { return; } // Name of the Eplan project sProjectName = Get_Name(sProject); // PDF - Export file name / path sFileExport = sDirPDF + sProjectName + ".pdf"; //MessageBox.Show("Pfad : " + sFileExport); Eplan.EplApi.ApplicationFramework.ActionCallingContext aPDF = new Eplan.EplApi.ApplicationFramework.ActionCallingContext(); aPDF.AddParameter("TYPE", "PDFPROJECTSCHEME"); aPDF.AddParameter("PROJECTNAME", sProject); aPDF.AddParameter("EXPORTFILE", sFileExport); //aPDF.AddParameter("EXPORTSCHEME", "Standard"); // Optional - enter here your EPLAN Export Scheme instead of "Standard" aPDF.AddParameter("BLACKWHITE", "1"); // PDF Print as Black & White Eplan.EplApi.ApplicationFramework.CommandLineInterpreter aEx = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); bool sRet = aEx.Execute("export", aPDF); if (!sRet) { System.Windows.Forms.MessageBox.Show("ERROR : PDF EXPORT"); } string SUBJECT = "Eplan Schematic : " + sProjectName; string BODY = "Original file path : " + sFileExport; string ATTACH = sFileExport; MAPI mapi = new MAPI(); // Definition email adresse / Optional //string ADDRESS = "YourEmail@...."; //mapi.AddRecipientTo(ADDRESS); //string ADDRESS2 = "YourEmail@...."; //mapi.AddRecipientTo(ADDRESS2); if (File.Exists(ATTACH)) { mapi.AddAttachment(ATTACH); } mapi.SendMailPopup(SUBJECT, BODY); // show E-mail before sending // mapi.SendMailDirect(SUBJECT, BODY); // or send E-mail directly } catch { return; } }
public void Execute(string filename) { if (string.IsNullOrEmpty(filename)) { return; } var mapi = new MAPI(); _fileName = filename; mapi.AddAttachment(filename); mapi.SendMailPopup(string.Empty, filename); }
private static IAddrBook ADX_GetAddrBook() { if (MAPI.MAPIInitialize(IntPtr.Zero) == MAPI.S_OK) { IntPtr sessionPtr = IntPtr.Zero; MAPI.MAPILogonEx(0, null, null, MAPI.MAPI_EXTENDED | MAPI.MAPI_ALLOW_OTHERS, out sessionPtr); if (sessionPtr == IntPtr.Zero) { MAPI.MAPILogonEx(0, null, null, MAPI.MAPI_EXTENDED | MAPI.MAPI_NEW_SESSION | MAPI.MAPI_USE_DEFAULT, out sessionPtr); } if (sessionPtr != IntPtr.Zero) { try { object sessionObj = Marshal.GetObjectForIUnknown(sessionPtr); if (sessionObj != null) { try { IMAPISession session = sessionObj as IMAPISession; if (session != null) { IntPtr addrBookPtr = IntPtr.Zero; session.OpenAddressBook(0, IntPtr.Zero, MAPI.AB_NO_DIALOG, out addrBookPtr); if (addrBookPtr != IntPtr.Zero) { try { object addrBookObj = Marshal.GetObjectForIUnknown(addrBookPtr); if (addrBookObj != null) { return(addrBookObj as IAddrBook); } } finally { Marshal.Release(addrBookPtr); } } } } finally { Marshal.ReleaseComObject(sessionObj); } } } finally { Marshal.Release(sessionPtr); } } } else { throw new ApplicationException("MAPI can not be initialized."); } return(null); }
public bool SetMsg() { iMsg = MAPI.GetMSG(); iMsgMem = MAPI.GetMemMSG(); if (iMsg == 0) { return(false); } else { return(true); } }
public bool SetHook() { int result = MAPI.SetHook(mHandle); if (result == 0) { return(false); } else { return(true); } }
private void btnSend_Click(object sender, EventArgs e) { MAPI mapi = new MAPI(); mapi.AddAttachment("c:\\temp\\file1.txt"); mapi.AddAttachment("c:\\temp\\file2.txt"); mapi.AddRecipientTo("*****@*****.**"); mapi.AddRecipientTo("*****@*****.**"); mapi.SendMailPopup("testing", "body text"); // Or if you want try and do a direct send without displaying the // mail dialog mapi.SendMailDirect("testing", "body text"); }
public void TestMAPI() { const string TEST_DATA_FILE_PATH = @"..\..\Data\test.txt"; string body = "Body Content here"; var file = TEST_DATA_FILE_PATH; string[] attachments = { file }; string[] recipients = { "EMAIL@DOMAIL" }; string subject = "Subject here"; MAPI mapi = new MAPI(); int result = mapi.ComposeMail(recipients, subject, body, attachments); Console.WriteLine("result: code={0}, status={1}", result, mapi.GetLastError()); }
public void Function(string ADDRESS,string SUBJECT, string BODY,string ATTACH) { MAPI mapi = new MAPI(); mapi.AddRecipientTo(ADDRESS); if (File.Exists(ATTACH)) { mapi.AddAttachment(ATTACH); } mapi.SendMailPopup(SUBJECT, BODY); // E-mail anzeigen //mapi.SendMailDirect(SUBJECT, BODY); //E-mail direkt versenden return; }
private void Email_Click(object sender, EventArgs e) { if (IsPreviewEmpty) { return; } List <string> fileNames = new List <string>(); ObjectInfo info = (sender as ButtonItem).Tag as ObjectInfo; if (info == null) { using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.Filter = Res.Get("FileFilters,PreparedReport"); dialog.DefaultExt = "*.fpx"; if (dialog.ShowDialog() == DialogResult.OK) { Save(dialog.FileName); fileNames.Add(dialog.FileName); } } } else { ExportBase export = Activator.CreateInstance(info.Object) as ExportBase; export.CurPage = CurrentPreview.PageNo; export.AllowOpenAfter = false; export.ShowProgress = true; export.Export(Report); fileNames = export.GeneratedFiles; } if (fileNames.Count > 0) { Form form = FindForm(); string[] recipientAddresses = Report.EmailSettings.Recipients == null ? new string[] { } : Report.EmailSettings.Recipients; int error = MAPI.SendMail(form == null ? IntPtr.Zero : form.Handle, fileNames.ToArray(), Report.EmailSettings.Subject, Report.EmailSettings.Message, new string[] {}, recipientAddresses); if (error > 1) { MessageBox.Show("MAPISendMail failed! " + MAPI.GetErrorText(error)); } } }
public void Function(string ADDRESS, string SUBJECT, string BODY, string ATTACH) { MAPI mapi = new MAPI(); mapi.AddRecipientTo(ADDRESS); if (File.Exists(ATTACH)) { mapi.AddAttachment(ATTACH); } mapi.SendMailPopup(SUBJECT, BODY); // E-mail anzeigen //mapi.SendMailDirect(SUBJECT, BODY); //E-mail direkt versenden return; }
public void emailFeatureRequest() { try { MAPI m = new MAPI(); m.AddRecipientTo("*****@*****.**"); String subject = "[LevelEditor] New feature request"; String body = "\r\r\n"; body += getPublicSignature(); m.SendMailPopup(subject, body); } catch (Exception) { MessageBox.Show("Hmmm... Something bad happened...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public MAPI GetEmail() { var mapi = new MAPI(); var allRecipients = GetAllRecipients(); foreach (var thisRecipient in allRecipients) { mapi.AddRecipientTo(thisRecipient.Trim()); } var allAttachments = GetAllAttachments(); foreach (var thisAttachment in allAttachments) { mapi.AddAttachment(thisAttachment.Trim()); } return(mapi); }
public void emailToDevelopers() { try { MAPI m = new MAPI(); m.AddAttachment(logfilename); m.AddRecipientTo("*****@*****.**"); String subject = "[LevelEditor] Please review my error log"; String body = ""; body += getPublicSignature(); m.SendMailPopup(subject, body); } catch (Exception) { MessageBox.Show("Hmmm... Something bad happened...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Invokes the default email client and prepoluates the fields from message. /// </summary> /// <param name="message">The message to prepopulate with.</param> /// <author>Jurie.smit</author> /// <datetime>2013/01/14-09:10 AM</datetime> public void SendCommunication(T message) { //Dev2Logger.Log.Debug(); MAPI mapi = new MAPI(); mapi.AddRecipientTo(message.To); if (!String.IsNullOrEmpty(message.AttachmentLocation)) { if (message.AttachmentLocation.Contains(";")) { var attachmentList = message.AttachmentLocation.Split(';'); attachmentList.ForEach(mapi.AddAttachment); } else { mapi.AddAttachment(@message.AttachmentLocation); } } mapi.SendMailPopup(message.Subject, message.Content); }
private void SendMailPdf(object sender, SendMailEventArgs args) { if (OnMail != null) { OnMail(sender, args); return; } #if REPMAN_MONO #else string mail_destination = args.To; string mail_subject = args.Subject; string mail_body = args.Body; string mail_filename = ""; string filename = args.Filename; string short_file_name = System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(filename), ".PDF"); if (mail_filename.Length > 0) { short_file_name = mail_filename; } MAPI.SendMail(mail_subject, mail_body, null, null, mail_destination, "", short_file_name, filename, true); #endif }
private void SendMailReport(object sender, SendMailEventArgs args) { if (OnMail != null) { OnMail(sender, args); return; } #if REPMAN_MONO #else string mail_destination = ""; string mail_subject = ""; string mail_body = ""; string mail_filename = ""; string filename = args.Filename; string short_file_name = System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(filename), ".PDF"); if (FReport.Params.IndexOf("MAIL_DESTINATION") >= 0) { mail_destination = FReport.Params["MAIL_DESTINATION"].Value.ToString(); } if (FReport.Params.IndexOf("MAIL_SUBJECT") >= 0) { mail_subject = FReport.Params["MAIL_SUBJECT"].Value.ToString(); } if (FReport.Params.IndexOf("MAIL_BODY") >= 0) { mail_body = FReport.Params["MAIL_BODY"].Value.ToString(); } if (FReport.Params.IndexOf("MAIL_FILE") >= 0) { mail_filename = FReport.Params["MAIL_FILE"].Value.ToString(); } if (mail_filename.Length > 0) { short_file_name = mail_filename; } MAPI.SendMail(mail_subject, mail_body, null, null, mail_destination, "", short_file_name, filename, true); #endif }
public bool FreeEx(IntPtr process, IntPtr address, int dataSize) { return(MAPI.VirtualFreeEx(process, address, dataSize, MAPI.FreeType.Decommit)); }
private void ZZ_Click(object sender, EventArgs e) { if (NR.Text != "" && NF.Text != "") { String Line = ""; String[] pobrane; Int32 i = 0; Double help = 0; if (File.Exists(Filename)) { StreamReader Zam = new StreamReader(Filename); List <String> Poz = new List <string>(); List <Double> ilości = new List <Double>(); if (change) { Zam.Close(); Zam = new StreamReader(Filename); while (Zam.EndOfStream == false) { Line = Zam.ReadLine(); pobrane = Line.Split(';'); if (Double.TryParse(pobrane[1], out help)) { if (help % 1 != 0) { help += 0.5; } Poz.Add(pobrane[0]); ilości.Add(help); i++; } } Zam.Close(); Boolean mm = false; Boolean test2 = false; for (Int32 a = 0; a < Poz.Count; a++) { if (ilości[a] > 0) { for (Int32 b = a + 1; b < Poz.Count; b++) { if (Poz[a] == Poz[b]) { ilości[a] += ilości[b]; ilości[b] = 0; } if (Poz[a] == "01.21FA000 V1" || Poz[a] == "01.23KA000 V1") { test2 = true; } } } } Boolean ww = false; if (test2) { for (Int32 a = 0; a < Poz.Count; a++) { if (Poz[a] == "02.Z10NE030E V1" || Poz[a] == "02.Z10V100E.01 V1" || Poz[a] == "02.Z10K800AE V1" || Poz[a] == "02.Z10NG120 V1" || Poz[a] == "02.Z10M200E V1") { mm = true; ilości[a] += 1; } else { mm = true; ww = true; } } } if (mm) { if (MessageBox.Show("W twoim zamówieniu znajdują się jednostki napędu SERVO-DRIVE do podnośników, więc dołączyliśmy jeden zasilacz z kompletem przewodów\n do zasilenia wszystkich urządzeń SERVO-DRIVE w podnośnikach w jednej kuchni.\n Jeżeli to ci wystarczy kliknij \"OK\", a jeżeli potrzebujesz więcej\n naciśnij \"Anuluj\" i poinformuj nas o tym w uwagach.", "SERVO-DRIVE do AVENTOS", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { string pom; string pom2; if (DateTime.Now.Month < 10) { pom = "0" + DateTime.Now.Month; } else { pom = DateTime.Now.Month.ToString(); } if (DateTime.Now.Day < 10) { pom2 = "0" + DateTime.Now.Day; } else { pom2 = DateTime.Now.Day.ToString(); } string sup = ""; Boolean test = false; char[] znaki = Path.GetInvalidFileNameChars(); for (Int32 w = 0; w < NR.TextLength; w++) { for (Int32 m = 0; m < znaki.Length; m++) { if (NR.Text[w] == znaki[m]) { test = true; break; } else { test = false; } } if (test) { sup += " "; } else { sup += NR.Text[w]; } } string zapis = "Zamówienie " + NF.Text + " " + DateTime.Now.Year + "." + pom + "." + pom2 + " " + sup; zamowienie.FileName = zapis; zamowienie.Filter = "Archiwum zip (.zip)|*.zip"; if (zamowienie.ShowDialog() == DialogResult.OK) { //try { Blum_Konfigurator.Properties.Settings.Default.Numer = Blum_Konfigurator.Properties.Settings.Default.Numer + 1; Blum_Konfigurator.Properties.Settings.Default.Save(); Filename = zamowienie.FileName; String folder = System.IO.Path.GetDirectoryName(zamowienie.FileName) + ".txt"; System.IO.Directory.CreateDirectory(Foldername); folder = Foldername + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - INDEX.txt"; string rap = "C:\\Users\\" + Environment.UserName + "\\folder_temp\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - Zestawienie.txt"; StreamReader temp = new StreamReader(Filename4); StreamWriter zap = new StreamWriter(rap, false); zap.WriteLine("Nazwa firmy: " + NF.Text); zap.WriteLine("Nr/nazwa zamówienia: " + NR.Text); zap.WriteLine("Termin realizacji: " + DataREa.Value.Day.ToString() + "." + DataREa.Value.Month.ToString() + "." + DataREa.Value.Year.ToString()); zap.Write(temp.ReadToEnd()); zap.WriteLine("Uwagi ogólne:"); if (Uwag.Text.Length > 0) { zap.WriteLine(Uwag.Text); } else { zap.WriteLine("Brak.\n"); } zap.WriteLine(toBin(Blum_Konfigurator.Properties.Settings.Default.Numer)); zap.Close(); temp.Close(); StreamWriter zapisujemy = new StreamWriter(folder, false); zapisujemy.WriteLine("Element;Ilość"); for (Int32 a = 0; a < Poz.Count; a++) { if (ilości[a] > 0) { zapisujemy.WriteLine(String.Format("{0};{1}", Poz[a], ilości[a])); } } if (ww) { zapisujemy.WriteLine(String.Format("02.Z10NE030E V1;1")); zapisujemy.WriteLine(String.Format("02.Z10V100E.01 V1;1")); zapisujemy.WriteLine(String.Format("02.Z10K800AE V1;1")); zapisujemy.WriteLine(String.Format("02.Z10NG120 V1;1")); zapisujemy.WriteLine(String.Format("02.Z10M200E V1;1")); } zapisujemy.Close(); folder = Foldername + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - Uwagi.txt"; StreamReader uwagi = new StreamReader(Filename2); String uwaga = uwagi.ReadToEnd(); uwagi.Close(); zapisujemy = new StreamWriter(folder); zapisujemy.WriteLine(NF.Text + "\n" + NR.Text + "\nTermin realizacji: " + DataREa.Value.Day.ToString() + "." + DataREa.Value.Month.ToString() + "." + DataREa.Value.Year.ToString()); zapisujemy.Write(uwaga); zapisujemy.WriteLine("Uwagi ogólne:"); if (Uwag.Text.Length > 0) { zapisujemy.WriteLine(Uwag.Text); } else { zapisujemy.WriteLine("Brak.\n"); } zapisujemy.Close(); if (File.Exists(Filename3)) { File.Move(Filename3, Foldername + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - Zobal.txt"); } String zip = System.IO.Path.GetDirectoryName(zamowienie.FileName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + ".zip"; if (File.Exists(zamowienie.FileName)) { File.Delete(zamowienie.FileName); } System.IO.Compression.ZipFile.CreateFromDirectory(Foldername, zamowienie.FileName); System.IO.Directory.Delete(Foldername, true); Save = true; change = false; if (MessageBox.Show("Czy wysłać zamówienie wiadomością e-mail?", "Wysyłanie zamówienia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MAPI mapi = new MAPI(); mapi.AddAttachment(zamowienie.FileName); mapi.AddRecipientTo("*****@*****.**"); mapi.SendMailPopup(Path.GetFileNameWithoutExtension(zamowienie.FileName), ""); } if (MessageBox.Show("Czy chcesz rozpocząć nowe zamówienie?", "Czy zacząć zamówienie?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { this.Close(); } else { if (File.Exists("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt"); } if (Directory.Exists("C:\\Users\\" + Environment.UserName + "\\folder_temp")) { Directory.Delete("C:\\Users\\" + Environment.UserName + "\\folder_temp", true); } if (File.Exists(Filename)) { StreamWriter czysc = new StreamWriter(Filename); czysc.Close(); } if (File.Exists(Filename2)) { StreamWriter czysc = new StreamWriter(Filename2); czysc.Close(); } NR.Text = ""; Uwag.Text = ""; Save = false; if (new Start().ShowDialog() == DialogResult.OK) { NR.Text = Program.Nazwa; if (File.Exists("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt"); } if (Directory.Exists("C:\\Users\\" + Environment.UserName + "\\folder_temp")) { Directory.Delete("C:\\Users\\" + Environment.UserName + "\\folder_temp", true); } Filename = "C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"; StreamWriter czysc = new StreamWriter(Filename); czysc.Close(); czysc = new StreamWriter(Filename2); czysc.Close(); } else { this.Close(); } } } // catch { //MessageBox.Show("Podczas zapisywania wystąpił błąd!", "Błąd podczas zapisywania", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { string pom, pom2; if (DateTime.Now.Month < 10) { pom = "0" + DateTime.Now.Month; } else { pom = DateTime.Now.Month.ToString(); } if (DateTime.Now.Day < 10) { pom2 = "0" + DateTime.Now.Day; } else { pom2 = DateTime.Now.Day.ToString(); } string sup = ""; Boolean test = false; char[] znaki = Path.GetInvalidFileNameChars(); for (Int32 w = 0; w < NR.TextLength; w++) { for (Int32 m = 0; m < znaki.Length; m++) { if (NR.Text[w] == znaki[m]) { test = true; break; } else { test = false; } } if (test) { sup += " "; } else { sup += NR.Text[w]; } } string zapis = "Zamówienie " + NF.Text + " " + DateTime.Now.Year + "." + pom + "." + pom2 + " " + sup; zamowienie.FileName = zapis; zamowienie.Filter = "Archiwum zip (.zip)|*.zip"; if (zamowienie.ShowDialog() == DialogResult.OK) { // try { Blum_Konfigurator.Properties.Settings.Default.Numer = Blum_Konfigurator.Properties.Settings.Default.Numer + 1; Blum_Konfigurator.Properties.Settings.Default.Save(); Filename = zamowienie.FileName; String folder = System.IO.Path.GetDirectoryName(zamowienie.FileName); System.IO.Directory.CreateDirectory(Foldername); folder = Foldername + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - INDEX.txt"; string rap = "C:\\Users\\" + Environment.UserName + "\\folder_temp\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - Zestawienie.txt"; StreamReader temp = new StreamReader(Filename4); StreamWriter zap = new StreamWriter(rap, false); zap.WriteLine("Nazwa firmy: " + NF.Text); zap.WriteLine("Nr/nazwa zamówienia: " + NR.Text); zap.WriteLine("Termin realizacji: " + DataREa.Value.Day.ToString() + "." + DataREa.Value.Month.ToString() + "." + DataREa.Value.Year.ToString()); zap.Write(temp.ReadToEnd()); zap.Write(temp.ReadToEnd()); zap.WriteLine("Uwagi ogólne:"); if (Uwag.Text.Length > 0) { zap.WriteLine(Uwag.Text); } else { zap.WriteLine("Brak.\n"); } zap.WriteLine(toBin(Blum_Konfigurator.Properties.Settings.Default.Numer)); zap.Close(); temp.Close(); StreamWriter zapisujemy = new StreamWriter(folder, false); zapisujemy.WriteLine("Element;Ilość"); for (Int32 a = 0; a < Poz.Count; a++) { if (ilości[a] > 0) { zapisujemy.WriteLine(String.Format("{0};{1}", Poz[a], ilości[a])); } } zapisujemy.Close(); folder = Foldername + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - Uwagi.txt"; StreamReader uwagi = new StreamReader(Filename2); String uwaga = uwagi.ReadToEnd(); uwagi.Close(); zapisujemy = new StreamWriter(folder); zapisujemy.WriteLine(NF.Text + "\n" + NR.Text + "\nTermin realizacji: " + DataREa.Value.Day.ToString() + "." + DataREa.Value.Month.ToString() + "." + DataREa.Value.Year.ToString()); zapisujemy.Write(uwaga); zapisujemy.WriteLine("Uwagi ogólne:"); zapisujemy.Write(Uwag.Text); zapisujemy.Close(); if (File.Exists(Filename3)) { File.Move(Filename3, Foldername + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + " - Zobal.txt"); } String zip = System.IO.Path.GetDirectoryName(zamowienie.FileName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(zamowienie.FileName) + ".zip"; if (File.Exists(zamowienie.FileName)) { File.Delete(zamowienie.FileName); } System.IO.Compression.ZipFile.CreateFromDirectory(Foldername, zamowienie.FileName); System.IO.Directory.Delete(Foldername, true); Save = true; change = false; try { if (MessageBox.Show("Czy wysłać zamówienie wiadomością e-mail?", "Wysyłanie zamówienia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MAPI mapi = new MAPI(); mapi.AddAttachment(zamowienie.FileName); mapi.AddRecipientTo("*****@*****.**"); mapi.SendMailPopup(Path.GetFileNameWithoutExtension(zamowienie.FileName), ""); } } catch { } if (MessageBox.Show("Czy chcesz rozpocząć nowe zamówienie?", "Czy zacząć zamówienie?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { this.Close(); } else { if (File.Exists("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt"); } if (Directory.Exists("C:\\Users\\" + Environment.UserName + "\\folder_temp")) { Directory.Delete("C:\\Users\\" + Environment.UserName + "\\folder_temp", true); } NR.Text = ""; Uwag.Text = ""; Save = false; if (new Start().ShowDialog() == DialogResult.OK) { NR.Text = Program.Nazwa; if (File.Exists("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uwagi_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\uchwyty_temp.txt"); } if (File.Exists("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt")) { File.Delete("C:\\Users\\" + Environment.UserName + "\\raport_temp.txt"); } if (Directory.Exists("C:\\Users\\" + Environment.UserName + "\\folder_temp")) { Directory.Delete("C:\\Users\\" + Environment.UserName + "\\folder_temp", true); } Filename = "C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"; StreamWriter czysc = new StreamWriter(Filename); czysc.Close(); Filename = "C:\\Users\\" + Environment.UserName + "\\zamowienie_temp.txt"; czysc = new StreamWriter(Filename2); czysc.Close(); } else { this.Close(); } } } //catch { // MessageBox.Show("Podczas zapisywania wystąpił błąd!", "Błąd podczas zapisywania", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { MessageBox.Show("Próbujesz zapisać puste zamówienie.", "Puste zamówienie", MessageBoxButtons.OK, MessageBoxIcon.Information); Zam.Close(); } } else { MessageBox.Show("Próbujesz zapisać puste zamówienie.", "Puste zamówienie", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Aby zapisać uzupełnij pola:\n-Nazwa zamawiającego\n-Nr\\nazwa zamówienia.", "Brak informacji", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Dispose() { MAPI.MAPIFreeBuffer(Ptr); Ptr = IntPtr.Zero; }
public void Close(IntPtr handle) { MAPI.CloseHandle(handle); }
//This code has been sourced from: //https://www.add-in-express.com/creating-addins-blog/2009/05/08/outlook-exchange-email-address-smtp/ //https://www.add-in-express.com/files/howtos/blog/adx-ol-smtp-address-cs.zip public static string ADX_GetSMTPAddress(string exchangeAddress) { string smtpAddress = string.Empty; IAddrBook addrBook = ADX_GetAddrBook(); if (addrBook != null) { try { IntPtr szPtr = IntPtr.Zero; IntPtr propValuePtr = Marshal.AllocHGlobal(16); IntPtr adrListPtr = Marshal.AllocHGlobal(16); Marshal.WriteInt32(propValuePtr, (int)MAPI.PR_DISPLAY_NAME); Marshal.WriteInt32(new IntPtr(propValuePtr.ToInt32() + 4), 0); szPtr = Marshal.StringToHGlobalAnsi(exchangeAddress); Marshal.WriteInt64(new IntPtr(propValuePtr.ToInt32() + 8), szPtr.ToInt32()); Marshal.WriteInt32(adrListPtr, 1); Marshal.WriteInt32(new IntPtr(adrListPtr.ToInt32() + 4), 0); Marshal.WriteInt32(new IntPtr(adrListPtr.ToInt32() + 8), 1); Marshal.WriteInt32(new IntPtr(adrListPtr.ToInt32() + 12), propValuePtr.ToInt32()); try { if (addrBook.ResolveName(0, MAPI.MAPI_DIALOG, null, adrListPtr) == MAPI.S_OK) { SPropValue spValue = new SPropValue(); int pcount = Marshal.ReadInt32(new IntPtr(adrListPtr.ToInt32() + 8)); IntPtr props = new IntPtr(Marshal.ReadInt32(new IntPtr(adrListPtr.ToInt32() + 12))); for (int i = 0; i < pcount; i++) { spValue = (SPropValue)Marshal.PtrToStructure( new IntPtr(props.ToInt32() + (16 * i)), typeof(SPropValue)); if (spValue.ulPropTag == MAPI.PR_ENTRYID) { IntPtr addrEntryPtr = IntPtr.Zero; IntPtr propAddressPtr = IntPtr.Zero; uint objType = 0; uint cb = (uint)(spValue.Value & 0xFFFFFFFF); IntPtr entryID = new IntPtr((int)(spValue.Value >> 32)); if (addrBook.OpenEntry(cb, entryID, IntPtr.Zero, 0, out objType, out addrEntryPtr) == MAPI.S_OK) { try { if (MAPI.HrGetOneProp(addrEntryPtr, MAPI.PR_EMS_AB_PROXY_ADDRESSES, out propAddressPtr) == MAPI.S_OK) { IntPtr emails = IntPtr.Zero; SPropValue addrValue = (SPropValue)Marshal.PtrToStructure(propAddressPtr, typeof(SPropValue)); int acount = (int)(addrValue.Value & 0xFFFFFFFF); IntPtr pemails = new IntPtr((int)(addrValue.Value >> 32)); for (int j = 0; j < acount; j++) { emails = new IntPtr(Marshal.ReadInt32(new IntPtr(pemails.ToInt32() + (4 * j)))); smtpAddress = Marshal.PtrToStringAnsi(emails); if (smtpAddress.IndexOf("SMTP:") == 0) { smtpAddress = smtpAddress.Substring(5, smtpAddress.Length - 5); break; } } } } finally { if (propAddressPtr != IntPtr.Zero) { Marshal.Release(propAddressPtr); } if (addrEntryPtr != IntPtr.Zero) { Marshal.Release(addrEntryPtr); } } } } } } } finally { Marshal.FreeHGlobal(szPtr); Marshal.FreeHGlobal(propValuePtr); Marshal.FreeHGlobal(adrListPtr); } } finally { Marshal.ReleaseComObject(addrBook); } } return(smtpAddress); }
public void WaitThread(IntPtr threadId) { MAPI.WaitForSingleObject(threadId, 10000); }
public IntPtr RemoteThread(IntPtr address) { return(MAPI.CreateRemoteThread(hReadProcess, IntPtr.Zero, 0, address, IntPtr.Zero, 0, IntPtr.Zero)); }
public IntPtr AllocEx(IntPtr process, int dataSize) { return(MAPI.VirtualAllocEx(process, IntPtr.Zero, (uint)dataSize, MAPI.AllocationType.Commit | MAPI.AllocationType.Reserve, MAPI.MemoryProtection.ExecuteReadWrite)); }