public bool SendMail(string to, string subject, string message) { email.Subject = (subject == String.Empty) ? "[OSJ] NUEVO Curso de Astronomía Observacional" : subject; email.Message = message; sendCount++; return(MailUtils.SendEmail(email, to)); }
public void SendEmailTest() { MailUtils target = new MailUtils(); // TODO: Initialize to an appropriate value string mailUrl = "*****@*****.**"; // TODO: Initialize to an appropriate value string title = "test"; // TODO: Initialize to an appropriate value string mailContent = "测试邮件服务器-Config"; // TODO: Initialize to an appropriate value bool expected = true; // TODO: Initialize to an appropriate value bool actual; actual = target.SendEmail(mailUrl, title, mailContent); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public bool CheckNewPublicIPAdress() { string auxPublicIP = IPUtils.GetPublicIP(); if ((auxPublicIP != PublicIP) || (String.IsNullOrEmpty(PublicIP) && String.IsNullOrEmpty(LocalIP))) { PublicIP = auxPublicIP; LocalIP = IPUtils.GetLocalIP(); email.Subject = "[WhatsMyIP] Se cambió la IP pública a " + PublicIP; email.Message = "<b>IP pública:</b> " + PublicIP + "\n <br />" + "<b>IP local:</b> " + LocalIP; email.Message += "\n <br /> \n <br /> <b><u>NETSTAT</u></b> \n <br />" + IPUtils.GetNetStat(); email.Message += "\n <br /> \n <br /> <b><u>GEOLOCALIZACION</u></b> \n <br />" + IPUtils.GetGeoLocationWithIP(this.PublicIP); MailUtils.SendEmail(email); return(true); } return(false); }
public void SendMailTest() { SMTPEmail email = new SMTPEmail(); email.From = ConfigurationManager.AppSettings["FromAddress"]; email.To = ConfigurationManager.AppSettings["ToAddress"]; email.SMTPClient = ConfigurationManager.AppSettings["SMTP"]; email.SMTPServer = ConfigurationManager.AppSettings["SMTP"]; email.SMTPPort = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]); email.Password = ConfigurationManager.AppSettings["Password"]; email.Domain = ConfigurationManager.AppSettings["Domain"]; email.IsSSL = bool.Parse(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["EnableSSL"])? ConfigurationManager.AppSettings["EnableSSL"] :"false"); email.UseDefaultCredentials = bool.Parse(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["UseDefaultCredentials"]) ? ConfigurationManager.AppSettings["UseDefaultCredentials"] : "false"); email.Subject = "[OSJ] SendMailTest "; email.Message = "Amigos de la Torre<br /><br />El viernes 21/03/14 comienza el curso de <b>'Astronomía Observacional'</b>, el objeto de este curso es que el alumno adquiera un conocimiento integral del cielo nocturno y aprenda paulatinamente conceptos como: sistemas de coordenadas, constelaciones, movimientos de los planetas, principales estrellas y lectura e interpretación de diferentes cartas celestes. El curso está basado principalmente en observaciones prácticas, con diferentes instrumentos, a fin de que los participantes logren familiarizarse rápidamente con el firmamento. Las observaciones con los instrumentos del observatorio se harán de acuerdo a las efemérides y a las condiciones meteorológicas." + "<br /><br /><b>Dados los contenidos y metodologías aplicadas en el curso, el mismo es para adultos y chicos de 12 años en adelante y no se necesitan conocimientos previos de matemática, física o astronomía.</b>" + "<b><br /><br /><ul><li>Comienzo: viernes 21/03/14</li><li>Duración: 4 clases</li><li>Horario: viernes de 20 a 22 hs</li><li>Arancel: $300 (se abonan el mismo día del inicio del curso) - Alumnos del Colegio San José gratis - Todo lo recaudado se destina al mantenimiento del observatorio</li><li>Dirección: Bartolomé Mitre 2455, Capital Federal (Colegio San José)</li><li>Informes e inscripción:<br />www.observatoriosanjose.com.ar<br />[email protected]<br />[email protected]</b></li></ul>"; Assert.IsTrue(MailUtils.SendEmail(email)); }
public void ProcessFile(string fileNameAndPath, string outputDir, string failedDir, string processedDir, string callerRef, string sentTo) { DocConverterFactory factory = new DocConverterFactory(); factory._logFile = _logFile; factory.StartConverter(); FileInfo file = new FileInfo(fileNameAndPath); try { IDocConverter converter = factory.GetDocConverter(file.FullName); converter.Convert(file.FullName, file.FullName, outputDir, processedDir, callerRef, sentTo); } catch (Exception e) { string mailMsg = "The file ''" + file.FullName + "'' has been moved to the directory " + failedDir + @"\" + Properties.Settings.Default.FailedSubDirConvert + ";" + Environment.NewLine + Environment.NewLine + "Reason:" + Environment.NewLine + "There was an issue converting this file to TIF format. " + Environment.NewLine + e.Message; MailUtils.SendEmail("Error", "Converting File", mailMsg, fileNameAndPath); FileUtils.MoveToDir(file, failedDir + @"\" + Properties.Settings.Default.FailedSubDirConvert); throw new FormatConversionException("Error: ''" + file.FullName + "'' has been moved to the directory " + failedDir + "; " + Environment.NewLine + e.Message); } factory.ShutdownConverter(); }
public void ProcessFile(string fileNameAndPath) { try { writeToDebugLog("ProcessFile", "----------------------------------------------------------"); writeToDebugLog("ProcessFile", "Processing: " + fileNameAndPath); string extWithPeriod = Path.GetExtension(fileNameAndPath); string ext = extWithPeriod.Replace(".", ""); string callerRef = getCallerRef(fileNameAndPath); //writeToDebugLog("ProcessFile", "callerRef=" + callerRef); string sentTo = getSentTo(fileNameAndPath); //writeToDebugLog("ProcessFile", "sentTo=" + sentTo); if (fileNameAndPath.Contains(THUMBS_DB)) { return; } else if (_validExtList.Contains(ext, StringComparer.OrdinalIgnoreCase)) { writeToDebugLog("ProcessFile", "ext=" + ext + " is a valid extension. Processing..."); writeToDebugLog("ProcessFile", "DocConverter - Initializing."); Controller controller = new Controller(); controller._logFile = _debugLog; writeToDebugLog("ProcessFile", "DocConverter - Sending sourceFile=" + fileNameAndPath + "; failedDir=" + this._failedDir + "; processedDir=" + this._processedDir); controller.ProcessFile(fileNameAndPath, this._outputDir, this._failedDir, "", callerRef, sentTo); writeToDebugLog("ProcessFile", "DocConverter - Completed."); //Move original data file to processed dir string origNameOnly = Path.GetFileName(fileNameAndPath); string datafileProcessedNameAndPath = Path.Combine(_processedDir, origNameOnly); bool processedFileExists = File.Exists(datafileProcessedNameAndPath); writeToDebugLog("ProcessFile", "Processed sourceFile(" + datafileProcessedNameAndPath + ") exists=" + processedFileExists); if (File.Exists(fileNameAndPath)) //jvc make sure not already moved due to fail { writeToDebugLog("ProcessFile", "Moving sourcefile to processedDir: " + datafileProcessedNameAndPath); FileUtils.MoveToDir(new FileInfo(fileNameAndPath), _processedDir); writeToDebugLog("ProcessFile", "Move file complete."); } writeToDebugLog("ProcessFile", "Processing Complete: " + fileNameAndPath); _EventLog.WriteToLog("--> ProcessFile - Complete: " + fileNameAndPath); } else { writeToDebugLog("ProcessFile", "Skipped File: " + fileNameAndPath); _EventLog.WriteToLog("-->** Skipped File: " + fileNameAndPath); string mailMsg = "The file ''" + fileNameAndPath + "'' was skipped because it is not in a supported format (" + Properties.Settings.Default.ValidFileExt + ")." + Environment.NewLine + "It has been moved to the directory " + _failedDir + @"\" + Properties.Settings.Default.FailedSubDirUnsupported + "."; MailUtils.SendEmail("Warning", "Unsupported File Format", mailMsg, fileNameAndPath); FileUtils.MoveToDir(new FileInfo(fileNameAndPath), _failedDir + @"\" + Properties.Settings.Default.FailedSubDirUnsupported); } //Israel 5/13/2015 -- address generated name collision. int milliseconds = 2000; Thread.Sleep(milliseconds); } catch (FormatConversionException ex) { writeToDebugLog("ProcessFile", "ERROR: " + ex.Message); _EventLog.WriteToLog("ERROR Processing: " + fileNameAndPath + "; " + ex.Message); } catch (Exception e) { string erMsg = "ERROR Processing: " + fileNameAndPath + "; " + Environment.NewLine + e.Message + "." + Environment.NewLine + Environment.NewLine + "Stack Trace:" + Environment.NewLine + e.StackTrace; writeToDebugLog("ProcessFile", erMsg); _EventLog.WriteToLog(erMsg); if (File.Exists(fileNameAndPath)) { string mailMsg = "The file ''" + fileNameAndPath + "'' has been moved to the directory " + this._failedDir + ";" + Environment.NewLine + Environment.NewLine + "Reason:" + Environment.NewLine + "There was an issue while processing this file. " + e.Message + "." + Environment.NewLine + Environment.NewLine + "Stack Trace:" + Environment.NewLine + e.StackTrace; MailUtils.SendEmail("Error", "Exception Processing Inbound File", mailMsg, fileNameAndPath); writeToDebugLog("ProcessFile", "Moving sourcefile to failedDir: " + fileNameAndPath); FileUtils.MoveToDir(new FileInfo(fileNameAndPath), this._failedDir); writeToDebugLog("ProcessFile", "Move file complete."); } else { string mailMsg = "There was an exception processing file ''" + fileNameAndPath + "'';" + Environment.NewLine + Environment.NewLine + "Reason:" + Environment.NewLine + e.Message + "." + Environment.NewLine + Environment.NewLine + "Stack Trace:" + Environment.NewLine + e.StackTrace; MailUtils.SendEmail("Error", "Exception Processing Inbound File", mailMsg, ""); } } }