public string CreareFolderRaportare() { string path = string.Format(@"c:\Stationari Ajustaj/{0}/{1}", DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MMMM")); try { // Determine whether the directory exists. if (Directory.Exists(path)) { // Console.WriteLine("That path exists already."); return(path); } // Try to create the directory. DirectoryInfo di = Directory.CreateDirectory(path); // Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path)); // Delete the directory. //di.Delete(); //Console.WriteLine("The directory was deleted successfully."); } catch (Exception ex) { LogMessegeRaportareAjustaj.WriteMessegeToLogFile(ex.Message.ToString()); //MessageBox.Show(ex.Message); // Console.WriteLine("The process failed: {0}", e.ToString()); //throw ex; } return(path); }
// Functie trimitere mail public static void TrimitereRaportMail(string adreseMailDeTrimis, string filePathDeTrimis, string subiect) { try { // "*****@*****.**", "[email protected], [email protected]" // Mail(emailFrom , emailTo) MailMessage mail = new MailMessage("*****@*****.**", adreseMailDeTrimis); //mail.From = new MailAddress("*****@*****.**"); mail.Subject = "Raport stationari utilaje ajustaj"; string Body = string.Format("Buna dimineata. <br>Atasat gasiti raport stationari utilaje ajustaj " + "<br>O zi buna."); mail.Body = Body; mail.IsBodyHtml = true; using (Attachment attachment = new Attachment(filePathDeTrimis)) { mail.Attachments.Add(attachment); SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Beltrame.1"); smtp.Port = 587; smtp.EnableSsl = true; smtp.Send(mail); mail = null; smtp = null; } // Console.WriteLine("Mail Sent succesfully"); } catch (Exception ex) { LogMessegeRaportareAjustaj.WriteMessegeToLogFile(ex.Message.ToString()); //MessageBox.Show(ex.Message); // Console.WriteLine(ex.ToString()); //throw ex; } }