Ejemplo n.º 1
0
        private void OpenCSV_button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
            if (openFileDialog1.ShowDialog() == true)
            {
                /*System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName);
                 * string _wholecsvstring = await sr.ReadToEndAsync();
                 * sr.Close();
                 * MessageBox.Show(_wholecsvstring);
                 */
                CSV_dt = DataTable.New.ReadCsv(@openFileDialog1.FileName);
                RecipientsList.Clear();

                foreach (Row row in CSV_dt.Rows)
                {
                    recipient newObject = new recipient
                    {
                        smtp = row.GetValueOrEmpty("recipientSMTPAddress"),
                        name = row.GetValueOrEmpty("recipientName"),
                        var1 = row.GetValueOrEmpty("var1"),
                        var2 = row.GetValueOrEmpty("var2"),
                        var3 = row.GetValueOrEmpty("var3"),
                        var4 = row.GetValueOrEmpty("var4"),
                        var5 = row.GetValueOrEmpty("var5")
                    };
                    RecipientsList.Add(newObject);
                }
                listBox.ItemsSource = RecipientsList;
                label1.Content      = "";
            }
        }
Ejemplo n.º 2
0
        void SendEmail(ExchangeService service, recipient _recipient)
        {
            EmailMessage message = new EmailMessage(service);

            message.Sender = new EmailAddress(ConfigurationSettings.AppSettings["EWSsendAsUser"]);
            message.ToRecipients.Add(_recipient.smtp);

            string _msgSubject = App.Current.Properties["MsgSubject"].ToString();

            _msgSubject = _msgSubject.Replace("###recipientName###", _recipient.name);
            _msgSubject = _msgSubject.Replace("###var1###", _recipient.var1);
            _msgSubject = _msgSubject.Replace("###var2###", _recipient.var2);
            _msgSubject = _msgSubject.Replace("###var3###", _recipient.var3);
            _msgSubject = _msgSubject.Replace("###var4###", _recipient.var4);
            _msgSubject = _msgSubject.Replace("###var5###", _recipient.var5);

            message.Subject = _msgSubject;

            string _msgBody = App.Current.Properties["MsgBody"].ToString();

            _msgBody = _msgBody.Replace("###recipientName###", _recipient.name);
            _msgBody = _msgBody.Replace("###var1###", _recipient.var1);
            _msgBody = _msgBody.Replace("###var2###", _recipient.var2);
            _msgBody = _msgBody.Replace("###var3###", _recipient.var3);
            _msgBody = _msgBody.Replace("###var4###", _recipient.var4);
            _msgBody = _msgBody.Replace("###var5###", _recipient.var5);

            _msgBody = _msgBody.Replace(Environment.NewLine, "<br />");


            message.Body  = @"<meta http-equiv='Content-Type' content='text/html; charset=us-ascii'>";
            message.Body += "<span style='font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 11pt;'>";
            message.Body += _msgBody;
            message.Body += "</span>";


            message.Body.BodyType = BodyType.HTML;

            if (ConfigurationSettings.AppSettings["SaveCopyInSentItems"] == "yes")
            {
                message.SendAndSaveCopy();
            }
            else
            {
                message.Send();
            }
        }