Exemplo n.º 1
0
        public static void SendMail(string address, string subject, string body, string attach)
        {
            if (!File.Exists(attach))
            {
                return;
            }

            try
            {
                #if __MonoCS__
                const string mailto = "'{0}' --subject '{1}' --body '{2}' --attach {3}";
                string       args   = string.Format(mailto, address, subject, body, attach);

                var proc = new System.Diagnostics.Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName  = "xdg-email";
                proc.StartInfo.Arguments = args;
                proc.Start();
                #else
                MapiMailMessage message = new MapiMailMessage(subject, body);
                message.Recipients.Add(address);
                message.Files.Add(attach);
                message.ShowDialog();
                #endif
            }
            catch (Exception ex)
            {
                Logger.WriteError("SysUtils.SendMail()", ex);
            }
        }
Exemplo n.º 2
0
        protected override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            var exportInformation = new ExportInformation(Designation, Description);

            MapiMailMessage.SendImage(surface, captureDetails);
            exportInformation.ExportMade = true;
            ProcessExport(exportInformation, surface);
            return(exportInformation);
        }
Exemplo n.º 3
0
        private void SendImageInEmail(FileInfo file)
        {
            string          subject = PluginSettings.Subject.ReplaceTokens(file);
            string          body    = PluginSettings.Message.ReplaceTokens(file);
            MapiMailMessage message = new MapiMailMessage(subject, body);

            message.Files.Add(file.Name);
            message.ShowDialog();
        }
Exemplo n.º 4
0
    /// <summary>
    /// Test method to create and show an email
    /// </summary>
    /// <param name="args"></param>
    static void Main(string[] args)
    {
        MapiMailMessage message = new MapiMailMessage("Test Message", "Test Body");

        message.Recipients.Add("*****@*****.**");
        message.Files.Add(@"C:\del.txt");
        message.ShowDialog();
        Console.ReadLine();
    }
Exemplo n.º 5
0
        public bool ShowEmailClient(Email email)
        {
            if (!IsClientInstalled)
            {
                return(false);
            }

            try
            {
                _logger.Info("Launched client email action");

                var message = new MapiMailMessage();

                message.Subject = email.Subject;
                message.Body    = email.Body;

                foreach (string recipient in email.To)
                {
                    if (recipient.Trim() != "")
                    {
                        message.Recipients.Add(recipient);
                    }
                }

                foreach (var attachment in email.Attachments)
                {
                    message.Files.Add(attachment.Filename);
                }

                _logger.Info("Start MAPI processing");

                if (StartInOwnThread)
                {
                    message.ShowDialogInOwnThread();
                }
                else
                {
                    message.ShowDialog();
                }

                _logger.Info("Done with MAPI");
                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error("Exception in MAPI Email client \r\n" + ex.Message);
                return(false);
            }
        }
Exemplo n.º 6
0
        private void emailFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in listView1.SelectedItems)
            {
                if (lvi.Tag != null)
                {
                    FileInfo fi = (FileInfo)lvi.Tag;


                    try
                    {
                        MapiMailMessage message = new MapiMailMessage("Send Secure Patient " + patientName + " " + mrn, "");
                        message.Files.Add(fi.FullName);
                        message.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        Logger.Instance.WriteToLog(ex.ToString());
                    }
                }
            }
        }
        public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            if (!isOutlookUsed)
            {
                using (Image image = surface.GetImageForExport()) {
                    MapiMailMessage.SendImage(image, captureDetails);
                    surface.Modified = false;
                    surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to " + mapiClient);
                }
                return(true);
            }

            // Outlook logic
            string tmpFile = captureDetails.Filename;

            if (tmpFile == null || surface.Modified)
            {
                using (Image image = surface.GetImageForExport()) {
                    tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
                }
            }
            else
            {
                LOG.InfoFormat("Using already available file: {0}", tmpFile);
            }

            // Create a attachment name for the image
            string attachmentName = captureDetails.Title;

            if (!string.IsNullOrEmpty(attachmentName))
            {
                attachmentName = attachmentName.Trim();
            }
            // Set default if non is set
            if (string.IsNullOrEmpty(attachmentName))
            {
                attachmentName = "Greenshot Capture";
            }
            // Make sure it's "clean" so it doesn't corrupt the header
            attachmentName = Regex.Replace(attachmentName, @"[^\x20\d\w]", "");

            if (outlookInspectorCaption != null)
            {
                OutlookEmailExporter.ExportToInspector(outlookInspectorCaption, tmpFile, attachmentName);
            }
            else
            {
                if (!manuallyInitiated)
                {
                    Dictionary <string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(conf.OutlookAllowExportInMeetings);
                    if (inspectorCaptions != null && inspectorCaptions.Count > 0)
                    {
                        List <IDestination> destinations = new List <IDestination>();
                        destinations.Add(new EmailDestination());
                        foreach (string inspectorCaption in inspectorCaptions.Keys)
                        {
                            destinations.Add(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
                        }
                        ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
                        PickerDestination.ShowMenuAtCursor(menu);
                        return(false);
                    }
                }
                OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, captureDetails.Title, attachmentName);
            }
            surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
            surface.Modified = false;

            // Don't know how to handle a cancel in the email

            return(true);
        }
Exemplo n.º 8
0
        static void InitializeExceptionHandler(UnhandledExceptionDlg exDlg)
        {
            exDlg.UserPrefChecked = false;

            // Add handling of OnShowErrorReport.
            // If you skip this then link to report details won't be showing.
            exDlg.OnShowErrorReportClick += delegate(object sender, SendExceptionClickEventArgs ar)
            {
                MessageBox.Show("[Message]\r\n" + ar.UnhandledException.Message + "\r\n\r\n"
                                + "[Version]\r\n" + Application.ProductVersion + "\r\n\r\n"
                                + "[WinVer]\r\n" + Environment.OSVersion.VersionString + "\r\n\r\n"
                                + "[Platform]\r\n" + Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") + "\r\n\r\n"
                                + "[StackTrace]\r\n" + PathScrubber.Scrub(ar.UnhandledException.ToString()) + "\r\n\r\n");
            };

            // Add handling of OnCopytoClipbooard
            // if you skip, the button is disabled
            exDlg.OnCopyToClipboardClick += delegate(object sender, SendExceptionClickEventArgs ar)
            {
                try
                {
                    // TUT: needs to be STA apt. thread for accessing clipboard
                    System.Threading.Thread clipThread = new System.Threading.Thread(delegate()
                    {
                        String body = Localizer.GetString("ErrorDescription");
                        body       += "\r\n\r\n[Description]\r\n\r\n\r\n\r\n";
                        body       += "[Message]\r\n" + ar.UnhandledException.Message + "\r\n\r\n";
                        body       += "[Version]\r\n" + Application.ProductVersion + "\r\n\r\n";
                        body       += "[WinVer]\r\n" + Environment.OSVersion.VersionString + "\r\n\r\n";
                        body       += "[Platform]\r\n" + Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") + "\r\n\r\n";
                        body       += "[StackTrace]\r\n" + PathScrubber.Scrub(ar.UnhandledException.ToString()) + "\r\n\r\n";

                        Clipboard.SetText(body);
                    });
                    clipThread.SetApartmentState(System.Threading.ApartmentState.STA);
                    clipThread.Start();
                }
                catch (Exception)
                {
                    // Ignore
                }
            };

            // Implement your sending protocol here. You can use any information from System.Exception
            exDlg.OnSendExceptionClick += delegate(object sender, SendExceptionClickEventArgs ar)
            {
                // User clicked on "Send Error Report" button:
                if (ar.SendExceptionDetails)
                {
                    String body = Localizer.GetString("ErrorDescription");
                    body += "\r\n\r\n[Description]\r\n\r\n\r\n\r\n";
                    body += "[Message]\r\n" + ar.UnhandledException.Message + "\r\n\r\n";
                    body += "[Version]\r\n" + Application.ProductVersion + "\r\n\r\n";
                    body += "[WinVer]\r\n" + Environment.OSVersion.VersionString + "\r\n\r\n";
                    body += "[Platform]\r\n" + Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") + "\r\n\r\n";
                    body += "[StackTrace]\r\n" + PathScrubber.Scrub(ar.UnhandledException.ToString()) + "\r\n\r\n";

                    MapiMailMessage message = new MapiMailMessage(@"inSSIDer 2 Error Report", body);
                    message.Recipients.Add("*****@*****.**");
                    message.ShowDialog(true);
                }

                Application.Exit();
            };
        }
Exemplo n.º 9
0
        private void emailFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem lvi in listView1.SelectedItems)
            {
                if (lvi.Tag != null)
                {
                    FileInfo fi = (FileInfo)lvi.Tag;

                    try
                    {
                        MapiMailMessage message = new MapiMailMessage("Send Secure Patient " + patientName + " " + mrn, "");
                        message.Files.Add(fi.FullName);
                        message.ShowDialog();

                    }
                    catch (Exception ex)
                    {
                        Logger.Instance.WriteToLog(ex.ToString());
                    }
                }
            }
        }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
 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);
     }
 }
        private void RunAutomark(string flags)
        {
            string path       = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;
            string directory  = System.IO.Path.GetDirectoryName(path);
            string executable = System.IO.Path.Combine(directory, "automark.exe");

            if (!System.IO.File.Exists(executable))
            {
                ShowMessage("automark - install error", "Could not find automark.exe");
                return;
            }
            if (!System.IO.Directory.Exists(m_localHistoryPath))
            {
                ShowMessage("automark - package dependency error", "autogit package is required, but has not been loaded for solution.");
                return;
            }

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;
            startInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
            startInfo.UseShellExecute        = false;
            startInfo.FileName  = executable;
            startInfo.Arguments = '"' + m_localHistoryPath + '"' + flags;
            process.StartInfo   = startInfo;
            process.Start();

            StringBuilder builder = new StringBuilder();

            while (!process.StandardOutput.EndOfStream)
            {
                string line = process.StandardOutput.ReadLine();
                builder.AppendLine(line);
            }

            StringBuilder buildForError = new StringBuilder();

            while (!process.StandardError.EndOfStream)
            {
                string line = process.StandardError.ReadLine();
                buildForError.AppendLine(line);
            }
            var error = buildForError.ToString();

            if (error.Trim().Length > 0)
            {
                ShowMessage("automark", error);
                //return;
            }


            if (flags.Contains("html"))
            {
                string tempHtml = System.IO.Path.Combine(m_basePath, "html", string.Format("automark-{0:yyyy-MM-dd-hh-mm-tt}.html", DateTime.Now));
                var    parent   = System.IO.Path.GetDirectoryName(tempHtml);
                if (!System.IO.Directory.Exists(parent))
                {
                    System.IO.Directory.CreateDirectory(parent);
                }

                System.IO.File.WriteAllText(tempHtml, builder.ToString());
                Log.WriteMessage(string.Format("automarkresult;{0};{1}", tempHtml, DateTime.Now));
                System.Diagnostics.Process.Start(tempHtml);
            }
            else if (flags.Contains("-export"))
            {
                var    time          = DateTime.Now;
                string tempExport    = System.IO.Path.Combine(m_basePath, "exports", string.Format("export-{0:yyyy-MM-dd-hh-mm-tt}.export", time));
                string tempExportZip = System.IO.Path.Combine(m_basePath, "exports", string.Format("export-{0:yyyy-MM-dd-hh-mm-tt}.zip", time));

                var parent = System.IO.Path.GetDirectoryName(tempExport);
                if (!System.IO.Directory.Exists(parent))
                {
                    System.IO.Directory.CreateDirectory(parent);
                }

                System.IO.File.WriteAllText(tempExport, builder.ToString());
                Zip.ZipFile(tempExportZip, tempExport);

                bool triedBackup = false;
                try
                {
                    MapiMailMessage message = new MapiMailMessage("Automark export", "This information includes the automark usage log, timestamps of saves and diffs, and generated html and markdown files.  This usage info will help in testing and improving the tool. You can review the exported info in " + tempExport + "  \nThanks!");
                    message.Recipients.Add("*****@*****.**");
                    message.Files.Add(tempExportZip);
                    message.OnDone += (success) =>
                    {
                        if (!success)
                        {
                            triedBackup = true;
                            string msg = @"mailto:[email protected]&subject=Automark export&body=Please attach {0} and send.";
                            System.Diagnostics.Process.Start(string.Format(msg, tempExportZip));
                        }
                    };
                    message.ShowDialog();
                }
                catch (Exception ex)
                {
                    if (!triedBackup)
                    {
                        string msg = @"mailto:[email protected]&subject=Automark export&body=Please attach {0} and send.";
                        System.Diagnostics.Process.Start(string.Format(msg, tempExportZip));
                    }
                }
            }
            else
            {
                string tempMD = System.IO.Path.Combine(m_basePath, "md", string.Format("automark-{0:yyyy-MM-dd-hh-mm-tt}.md", DateTime.Now));
                var    parent = System.IO.Path.GetDirectoryName(tempMD);
                if (!System.IO.Directory.Exists(parent))
                {
                    System.IO.Directory.CreateDirectory(parent);
                }

                System.IO.File.WriteAllText(tempMD, builder.ToString());
                Log.WriteMessage(string.Format("automarkresult;{0};{1}", tempMD, DateTime.Now));
                System.Diagnostics.Process.Start(tempMD);
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Adds a new recipient with the specified address, display name and recipient type to this collection.
 /// </summary>
 public void Add(string address, string displayName, MapiMailMessage.RecipientType recipientType)
 {
     this.Add(new Recipient(address, displayName, recipientType));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Adds a new recipient with the specified address and recipient type to this collection.
 /// </summary>
 public void Add(string address, MapiMailMessage.RecipientType recipientType)
 {
     this.Add(new Recipient(address, recipientType));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a new recipient with the specified address, display name and recipient type.
 /// </summary>
 public Recipient(string address, string displayName, MapiMailMessage.RecipientType recipientType)
 {
     Address = address;
     DisplayName = displayName;
     RecipientType = recipientType;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a new recipient with the specified address and recipient type.
 /// </summary>
 public Recipient(string address, MapiMailMessage.RecipientType recipientType)
 {
     Address = address;
     RecipientType = recipientType;
 }