Exemplo n.º 1
0
        // Send mail
        public static void SendMail(string path, fHdr line)
        {
            using (MailMessage mail = new MailMessage())
            {
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add("*****@*****.**");
                mail.Subject = "EDI ";
                mail.Body = "There are unposted documents";
                mail.IsBodyHtml = true;
                //mail.UseDefaultCredentials = false;

                // Can set to false, if you are sending pure text.
                mail.Attachments.Add(new Attachment(CreateLogFile(path, line)));
                using (SmtpClient smtp = new SmtpClient("mail.meidanis.gr", 587))
                {
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new NetworkCredential("*****@*****.**", "edi@meidanis");
                    smtp.EnableSsl = false;
                    smtp.Send(mail);
                }
            }
        }
Exemplo n.º 2
0
        // Populate headers object
        public static List<fHdr> CreateHeader(string[] HFileContent, Dictionary<string, string> stores, Dictionary<string, string> coetType)
        {
            var mHdrs = new List<fHdr>();
            int i = 0;
            foreach (var headerLine in HFileContent)
            {
                var line = new fHdr();
                string[] token = headerLine.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (PropertyInfo prop in line.GetType().GetProperties())
                {
                    string t = prop.PropertyType.ToString();
                    switch (t)
                    {
                        case "System.String":
                            string tmps;
                            if (stores.ContainsKey(Convert.ToString(token[i])))
                                tmps = Convert.ToString(stores[Convert.ToString(token[i])]);
                            else if (coetType.ContainsKey(Convert.ToString(token[i])))
                                tmps = Convert.ToString(coetType[Convert.ToString(token[i])]);
                            else
                                tmps = Convert.ToString(token[i]);
                            prop.SetValue(line, tmps);
                            break;
                        case "System.Decimal":
                            decimal tmp = Convert.ToDecimal(token[i]);
                            prop.SetValue(line, tmp);
                            break;
                        case "System.DateTime":
                            DateTime dateID = DateTime.ParseExact(token[i].ToString(), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);
                            prop.SetValue(line, dateID);
                            break;
                    }
                    i++;
                }
                mHdrs.Add(line);
                i = 0;
            }
            return mHdrs;
        }
Exemplo n.º 3
0
 // Create log file
 public static string CreateLogFile(string path, fHdr line)
 {
     string logPath = path + "\\log.txt";
     using (StreamWriter sw = new StreamWriter(logPath, true))
     {
         sw.WriteLine("Ημερομηνία Παραστατικού: {0} Κωδικός Παραστατικού {3}  ΑΦΜ Προμηθευτή: {1} ,Ημερομηνία εκτέλεσης {2}", line.Tradedate, line.SupplierTin, DateTime.Now.ToString(), line.TradeCode);
     }
     return logPath;
 }