Пример #1
0
        public void ExporPdfAndSendMail()
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Narudzbe";
            if (!Directory.Exists(appPath))
            {
                Directory.CreateDirectory(appPath);
            }
            string[] prezime = narucitelj.Split(' ');

            string pathPdf = appPath + "\\Narudžba Multiseta_" +
                    prezime[prezime.Length-1] + "_" +
                    krajnjiKupac + "_" +
                    DateTime.Now.Day + "_" +
                    DateTime.Now.Month + "_" +
                    DateTime.Now.Year + "_" +
                    DateTime.Now.Hour + "_" +
                    DateTime.Now.Minute + "_" +
                    DateTime.Now.Second + "_" + ".pdf";
            try
            {
                exportToPdf(pathPdf);
                var array = new GetConfigData();
                if (array.GetEmails() != null)
                {
                    foreach (string email in array.GetEmails())
                    {
                        Array.Resize(ref recipients, recipients.Length + 1);
                        recipients[recipients.Length - 1] = email;
                    }
                }
                else
                {
                    if (lang == "ENG")
                    {
                        MessageBox.Show("Error while validating e-mail adresses. Please check application setttings.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Greška kod provjere e-mail adresa. Provjerite postavke aplikacije.", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                string body = "";
                var file = pathPdf;
                string[] attachments = new string[] { file };
                string subject = "Narudžba Multiseta_" +
                    prezime[prezime.Length - 1] + "_" +
                    krajnjiKupac + "_" +
                    DateTime.Now.Day + "_" +
                    DateTime.Now.Month + "_" +
                    DateTime.Now.Year + "_" +
                    DateTime.Now.Hour + "_" +
                    DateTime.Now.Minute + "_" +
                    DateTime.Now.Second;
                ActiveControl = null;
                new Methods.MAPI().ComposeMail(recipients, subject, body, attachments);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Greška", 0, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void RefreshGrid()
        {
            if (Settings.Default.emails.Count > 0)
            {
                string[] recipients = { };
                var cd = new GetConfigData();
                foreach (string email in cd.GetEmails())
                {
                    Array.Resize(ref recipients, recipients.Length + 1);
                    recipients[recipients.Length - 1] = email;
                }
                grdEmails.DataSource = recipients.Select(x => new { Email = x }).ToList();
                grdEmails.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

                grdEmails.Refresh();
            }
            else
            {
                grdEmails.DataSource = null;
            }
        }