Esempio n. 1
0
 public ReceiveReport()
 {
     InitializeComponent();
     ConfigData     = (NameValueCollection)ConfigurationManager.GetSection("appSettings");
     lm.LogFilePath = ConfigData.Get("logFilePath");  //full path with trailing "\"
     lm.LogFile     = ConfigData.Get("logFile");
     lm.Write(dtu.DateTimeToShortDate(DateTime.Now));
     om.Debug          = Convert.ToBoolean(ConfigData.Get("debug"));
     om.AttachmentPath = ConfigData.Get("xport_path");
     om.DateTimeCoded  = dtu.DateTimeCoded();
     om.LogPath        = ConfigData.Get("logFilePath");
     recipientList     = ConfigData.Get("recipientList");
     recipients        = recipientList.Split(",".ToCharArray());
     ODMDataSetFactory = new ODMDataFactory();
     xportPath         = ConfigData.Get("xport_path");
     dbConnect         = ConfigData.Get("connect");
     foreach (string recipient in recipients)
     {
         om.RecipientList.Add(recipient);
     }
     LoadDataSet();
 }
Esempio n. 2
0
        private void SendMail()
        {
            string[] mailList = emailList.Split(";".ToCharArray());
            string[] ccList   = emailCopyTo.Split(";".ToCharArray());
            try
            {
                foreach (string recipient in mailList)
                {
                    if (recipient.Trim().Length > 0)
                    {
                        MailMessage mail       = new MailMessage();
                        SmtpClient  SmtpServer = new SmtpClient("smtp.uw.edu");
                        mail.To.Add(recipient);
                        mail.From = new MailAddress("*****@*****.**");
                        if (emailCopyTo.Length > 0)
                        {
                            foreach (string cc in ccList)
                            {
                                mail.CC.Add(cc);
                            }
                        }
                        mail.Subject = "Stock Status Report for " + dtu.DateTimeToShortDate(DateTime.Now);
                        mail.Body    = (firstName.Length > 0
                            ? firstName + "," + Environment.NewLine + Environment.NewLine
                            : "") +
                                       "Here's the MPOUS Stock Status Report for " + dtu.DateTimeToShortDate(DateTime.Now) +
                                       Environment.NewLine +
                                       Environment.NewLine +
                                       Environment.NewLine +
                                       Environment.NewLine +
                                       Environment.NewLine +
                                       "PMMHelp" + Environment.NewLine +
                                       "UW Medicine Harborview Medical Center" + Environment.NewLine +
                                       "Supply Chain Management Informatics" + Environment.NewLine +
                                       "206-598-0044" + Environment.NewLine +
                                       "*****@*****.**";
                        mail.ReplyToList.Add(emailReplyTo);

                        Attachment attachment;
                        attachment =
                            new System.Net.Mail.Attachment(outFileName);

                        mail.Attachments.Add(attachment);

                        SmtpServer.Port        = 587;
                        SmtpServer.Credentials = new System.Net.NetworkCredential("pmmhelp", GetKey());
                        SmtpServer.EnableSsl   = true;
                        SmtpServer.Send(mail);
                        lm.Write("Process/SendMail:  " + recipient);
                        if (emailCopyTo.Length > 0)
                        {
                            lm.Write("Process/Send_Mail/CC:  " + emailCopyTo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string mssg = ex.Message;
                lm.Write("Process/SendMail_:  " + mssg);
            }
        }