protected void UpdateLabelsWithLang(CultureInfo info) { Localisation loc = Localisation.getInstance(); this.Text = loc.getString(info.TwoLetterISOLanguageName, this.Text); this.TB_RENAME.Text = mailitem.Subject; this.LABEL_DESTINATION.Text = loc.getString(info.TwoLetterISOLanguageName, this.LABEL_DESTINATION.Text); this.LABEL_RENAME.Text = loc.getString(info.TwoLetterISOLanguageName, this.LABEL_RENAME.Text); this.bt_ok.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_ok.Text); this.bt_cancel.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_cancel.Text); this.cb_explode_attachements.Text = loc.getString(info.TwoLetterISOLanguageName, this.cb_explode_attachements.Text); }
protected void UpdateLabelsWithLang(CultureInfo info) { Localisation loc = Localisation.getInstance(); this.Text = loc.getString(info.TwoLetterISOLanguageName, this.Text); this.label1.Text = loc.getString(info.TwoLetterISOLanguageName, this.label1.Text); this.ch_date.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_date.Text); this.ch_subject.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_subject.Text); this.ch_state.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_state.Text); this.ch_destination.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_destination.Text); this.bt_close.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_close.Text); this.bt_cancel.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_cancel.Text); }
public void ShowDlg() { if (MessageBox.Show( Localisation.getInstance().getString(culture.TwoLetterISOLanguageName, "MESSAGE_ARE_YOU_SURE"), Localisation.getInstance().getString(culture.TwoLetterISOLanguageName, "FORM_ARCHIVE_TO_DISK_TITLE"), MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } t = new Thread(archiver.MassArchive); t.Start(); this.ShowDialog(); }
private void bt_ok_Click(object sender, EventArgs e) { this.Hide(); // réécriture du fichier de destinations précedentes if (!lines.Contains(tb_destination.Text)) { string[] newlines = new string[lines.Length + 1]; newlines[0] = tb_destination.Text; Array.ConstrainedCopy(lines, 0, newlines, 1, lines.Length); File.WriteAllLines(filename, newlines); } archiver = new Archiver(this.tb_destination.Text, this); if (this.cb_explode_attachements.Checked) { archiver.EnableExtractAttachments(); } if (Config.GetInstance().GetOption("TRUNCATE_PATH_TOO_LONG").Equals("TRUE")) { archiver.EnableTruncatePathTooLong(); } if (Config.GetInstance().GetOption("ASK_PATH_TOO_LONG").Equals("TRUE")) { archiver.EnableAskPathTooLong(); } string res = archiver.ArchiveItem(mailitem, this.tb_destination.Text, this.TB_RENAME.Text); if (res == "Ok") { var customCat = Localisation.getInstance().getString( culture.TwoLetterISOLanguageName, "ARCHIVED_CATEGORY" ); if (mailitem.Categories == null || mailitem.Categories.Trim().Equals("")) // no current categories assigned { mailitem.Categories = customCat; } else if (!mailitem.Categories.Contains(customCat)) // insert as first assigned category { mailitem.Categories = string.Format("{0}, {1}", customCat, mailitem.Categories); } mailitem.Save(); } MessageBox.Show(res); this.Dispose(); }
private void AddACategory() { Outlook.Categories categories = Application.Session.Categories; string categorie = Localisation.getInstance().getString( Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName, "ARCHIVED_CATEGORY" ); if (!CategoryExists(categorie)) { Outlook.Category category = categories.Add(categorie, Outlook.OlCategoryColor.olCategoryColorGreen); } }
private void UpdateLabelsWithLang(CultureInfo info) { Localisation loc = Localisation.getInstance(); this.Text = loc.getString(info.TwoLetterISOLanguageName, this.Text); this.label1.Text = loc.getString(info.TwoLetterISOLanguageName, this.label1.Text); this.textColumn1.Text = loc.getString(info.TwoLetterISOLanguageName, this.textColumn1.Text); this.textColumn2.Text = loc.getString(info.TwoLetterISOLanguageName, this.textColumn2.Text); this.bt_ok.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_ok.Text); this.cb_explode_attachments.Text = loc.getString(info.TwoLetterISOLanguageName, this.cb_explode_attachments.Text); this.cb_truncate.Text = loc.getString(info.TwoLetterISOLanguageName, this.cb_truncate.Text); this.cb_ask_path_too_long.Text = loc.getString(info.TwoLetterISOLanguageName, this.cb_ask_path_too_long.Text); this.tabPage1.Text = loc.getString(info.TwoLetterISOLanguageName, this.tabPage1.Text); this.tabPage2.Text = loc.getString(info.TwoLetterISOLanguageName, this.tabPage2.Text); this.cb_add_categories_in_name.Text = loc.getString(info.TwoLetterISOLanguageName, this.cb_add_categories_in_name.Text); }
protected void UpdateLabelsWithLang(CultureInfo info) { Localisation loc = Localisation.getInstance(); this.Text = loc.getString(info.TwoLetterISOLanguageName, this.Text); this.label1.Text = loc.getString(info.TwoLetterISOLanguageName, this.label1.Text); this.ch_date.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_date.Text); this.ch_subject.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_subject.Text); this.ch_etat.Text = loc.getString(info.TwoLetterISOLanguageName, this.ch_etat.Text); this.label2.Text = loc.getString(info.TwoLetterISOLanguageName, this.label2.Text); this.bt_ok.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_ok.Text); this.bt_close.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_close.Text); this.label3.Text = loc.getString(info.TwoLetterISOLanguageName, this.label3.Text); this.bt_cancel.Text = loc.getString(info.TwoLetterISOLanguageName, this.bt_cancel.Text); this.cb_explode_attachements.Text = loc.getString(info.TwoLetterISOLanguageName, this.cb_explode_attachements.Text); }
public void Archive() { var customCat = Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "ARCHIVED_CATEGORY" ); string msg; int cpt = 0; foreach (var item in parent.selection) { if (shouldStop) { parent.Invoke(parent.endArchiveDelegate); return; } msg = ArchiveItem(item); if (msg.Equals("Ok")) { if (item.Categories == null || item.Categories.Trim().Equals("")) // no current categories assigned { item.Categories = customCat; } else if (!item.Categories.Contains(customCat)) // insert as first assigned category { item.Categories = string.Format("{0}, {1}", customCat, item.Categories); } item.Save(); } parent.Invoke(parent.updateItemDelegate, new object[] { item.EntryID, msg }); cpt++; Thread.Sleep(10); } parent.Invoke(parent.endArchiveDelegate); }
public void MassArchive() { if (Config.GetInstance().GetOption("EXPLODE_ATTACHMENTS").Equals("TRUE")) { EnableExtractAttachments(); } if (Config.GetInstance().GetOption("TRUNCATE_PATH_TOO_LONG").Equals("TRUE")) { EnableTruncatePathTooLong(); } if (Config.GetInstance().GetOption("ASK_PATH_TOO_LONG").Equals("TRUE")) { EnableAskPathTooLong(); } string msg; var customCat = Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "ARCHIVED_CATEGORY" ); var binding = Config.GetInstance().GetFoldersBinding(); Outlook.Folder root = parent.olApplication.Session.DefaultStore.GetRootFolder() as Outlook.Folder; foreach (string key in binding.Keys) { // get the mapi folder from ID Outlook.Folder folder = EnumerateFolders(root, key); if (folder.EntryID == key) { // iterate mails in folder foreach (var item in folder.Items) { if (item is Outlook.MailItem mailitem) { // if no category or not categorised as achived, archive and continue if (mailitem.Categories == null || mailitem.Categories.Trim().Equals("") || !mailitem.Categories.Contains(customCat)) { // archive items msg = ArchiveItem(mailitem, binding[key], null); // update categories if needed if (msg.Equals("Ok")) { if (mailitem.Categories == null || mailitem.Categories.Trim().Equals("")) // no current categories assigned { mailitem.Categories = customCat; } else if (!mailitem.Categories.Contains(customCat)) // insert as first assigned category { mailitem.Categories = string.Format("{0}, {1}", customCat, mailitem.Categories); } mailitem.Save(); } // add line to form parent.Invoke(parent.addLIneDelegate, new object[] { mailitem, binding[key], msg }); } else // already categorised { parent.Invoke(parent.addLIneDelegate, new object[] { mailitem, "", Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "ALREADY_CATEGORISED_AS_ARCHIVED") }); } } } } } parent.Invoke(parent.endArchiveDelegate); }
public string ArchiveItem(Outlook.MailItem item, string dir, string newname) { string archived = "erreur"; string shortFilename = String.Format("{0:yyyy-MM-dd_HHmmss}", item.ReceivedTime) + "-"; if (Config.GetInstance().GetOption("ADD_CATEGORIES_IN_FILENAME") == "TRUE") { if (item.Categories != null) { shortFilename += item.Categories.Replace(';', '-') + "-"; } } if (newname != null) { shortFilename += CleanFileName(newname); } else { shortFilename += CleanFileName(item.Subject); } string filename = Path.Combine(dir, shortFilename + ".msg"); // si extraction dans dossier séparé, on redéfini le filename if (extractAttachments) { dir = Path.Combine(dir, shortFilename); filename = Path.Combine(dir, shortFilename + ".msg"); } // si on fleurte avec les limites, on ne sauve pas if (dir.Length > 230) { return(Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "PATH_TOO_LONG" )); } // si on fleurte avec les limites, on ne sauve pas if (filename.Length > 250) { if (truncatePathTooLong) { filename = filename.Substring(0, 250) + ".msg"; } else if (askPathTooLong) { do { string error = Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "FULL_PATH_TOO_LONG" ); shortFilename = SingleQuestionForm.Ask( Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "QUESTION_FULL_PATH_TOO_LONG" ), shortFilename, null, null, error); filename = Path.Combine(dir, shortFilename + ".msg"); } while (filename.Length > 254 || File.Exists(filename)); } else { return(Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "FULL_PATH_TOO_LONG" )); } } // si fichier déjà existant, on ne sauve pas if (File.Exists(filename)) { return(Localisation.getInstance().getString( parent.culture.TwoLetterISOLanguageName, "FILE_ALREADY_EXISTS" )); } // si extraction des attachements, on est OK sur longueur et not exists, on tente de créer le répertoire if (extractAttachments) { Directory.CreateDirectory(dir); } // on tente de sauver try { item.SaveAs(filename, Outlook.OlSaveAsType.olMSGUnicode); // si extration des attachements, on extract if (extractAttachments) { foreach (Outlook.Attachment att in item.Attachments) { att.SaveAsFile(Path.Combine(dir, att.FileName)); } } archived = "Ok"; } catch (Exception e) { archived = e.Message; } return(archived); }