コード例 #1
0
ファイル: PreviewControl.cs プロジェクト: zixing131/LAEACC
        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));
                }
            }
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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
        }