internal static void SendNoteAsText(PNote note, string recipients = "", string linkToRemove = "") { try { var text = ""; if (note.Visible) { text = note.Dialog.Edit.Text; } else { var path = Path.Combine(PNPaths.Instance.DataDir, note.ID + PNStrings.NOTE_EXTENSION); if (File.Exists(path)) { var rtb = new RichTextBox(); LoadNoteFile(rtb, path); text = rtb.Text; } } //remove possible link if (!string.IsNullOrEmpty(linkToRemove)) { text = text.Replace(linkToRemove, ""); } var profile = PNStatic.SmtpProfiles.FirstOrDefault(c => c.Active); if (profile == null) { text = text.Replace("\n", "%0D%0A"); text = text.Replace("\r", "%0D%0A"); text = text.Replace("\"", "%22"); text = text.Replace("&", "%26"); var mailMessage = new MapiMailMessage { Subject = PNLang.Instance.GetMessageText("mail_subject_text", "Sent from PNotes. Note name:") + @" " + note.Name, Body = text }; if(!string.IsNullOrEmpty(recipients)) { var recips = recipients.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries); foreach (var r in recips) { mailMessage.Recipients.Add(r); } } mailMessage.ShowDialog(); } else { var dlgSend = new WndSendSmtp(profile, note.Name, recipients, text, null); dlgSend.ShowDialog(); } } catch (Exception ex) { PNStatic.LogException(ex); } }
internal static void SendNotesAsAttachments(List<string> files) { try { var profile = PNStatic.SmtpProfiles.FirstOrDefault(c => c.Active); if (profile == null) { var mailMessage = new MapiMailMessage(); foreach (var f in files) { mailMessage.Files.Add(f); } mailMessage.Subject = PNLang.Instance.GetMessageText("mail_subject_attachment", "Sent from PNotes."); mailMessage.ShowDialog(); } else { var dlgSend = new WndSendSmtp(profile, null, null, files); dlgSend.ShowDialog(); } } catch (Exception ex) { PNStatic.LogException(ex); } }