diff --git a/Jenkinsfile b/Jenkinsfile index 5b2e1cc..b0d1c7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=620']) { + withEnv(['NEXT_BUILD_NUMBER=621']) { // env.versionNumber = VersionNumber(versionNumberString : '3.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '3.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'SteamWareLib' diff --git a/SteamWareLib/utils.cs b/SteamWareLib/utils.cs index 059ffbc..90898d3 100644 --- a/SteamWareLib/utils.cs +++ b/SteamWareLib/utils.cs @@ -1,5 +1,7 @@ +using AegisImplicitMail; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Data; using System.Globalization; using System.IO; @@ -565,12 +567,101 @@ namespace SteamWare /// allegati del messaggio public bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati) { + bool answ = false; // sostituisco eventuali a capo nel corpo messaggio... _corpo = _corpo.Replace("\r", "
"); _corpo = _corpo.Replace("\n", "
"); - //manda email... + //_useAIMSmtp + if (memLayer.ML.CRB("_useAIMSmtp")) + { + answ = sendWithAIMClient(_mailFrom, _mailTo, _oggetto, _corpo, _allegati); + } + else + { + answ = sendWithNetClient(_mailFrom, _mailTo, _oggetto, _corpo, _allegati); + } + + return answ; + } + /// + /// Invia con metodo del client AIM x compatilbiiltà SSL implicito & co + /// https://sourceforge.net/projects/netimplicitssl/ + /// + /// + /// + /// + private bool sendWithAIMClient(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati) + { + // Generate Message + var mymessage = new MimeMailMessage(); + mymessage.From = new MimeMailAddress(_mailFrom); + mymessage.To.Add(_mailTo); + mymessage.Subject = _oggetto; + mymessage.Body = _corpo; +#if false + // eventualmente aggiungo allegati... + foreach (AlternateView allegato in _allegati) + { + mymessage.Attachments.Add((MimeAttachment)allegato); + } +#endif + + // Create Smtp Client + int port = 465; + if (memLayer.ML.CRS("_PortSSL") != "") + { + port = memLayer.ML.CRI("_PortSSL"); + } + var mailer = new MimeMailer(_smtpCli, port); + mailer.User = _username; + mailer.Password = _password; + if (memLayer.ML.confReadBool("_enableSSL")) + { + mailer.SslType = SslMode.Ssl; + } + mailer.AuthenticationMode = AuthenticationType.Base64; + + //Set a delegate function for call back + mailer.SendCompleted += compEvent; + mailer.SendMailAsync(mymessage); + return true; + } + /// + /// CallBack chiusura invio + /// + /// + /// + private void compEvent(object sender, AsyncCompletedEventArgs e) + { + if (e.UserState != null) + { + Console.Out.WriteLine(e.UserState.ToString()); + } + + Console.Out.WriteLine("is it canceled? " + e.Cancelled); + + if (e.Error != null) + { + Console.Out.WriteLine("Error : " + e.Error.Message); + } + } + + + /// + /// Invia con metodo del client Net standard + /// + /// email mittente + /// email destinatario + /// oggetto dell'email + /// corpo del messaggio + /// allegati del messaggio + /// + private bool sendWithNetClient(string _mailFrom, string _mailTo, string _oggetto, string _corpo, AlternateView[] _allegati) + { + // compone messaggio MailMessage messaggio = new MailMessage(_mailFrom, _mailTo, _oggetto, _corpo); messaggio.IsBodyHtml = true; + //manda email... SmtpClient _smtpClient = new SmtpClient(_smtpCli); // se ci sono credenziali utente... if (_username != "") @@ -605,6 +696,7 @@ namespace SteamWare return false; } } + /// /// procedura invio email /// @@ -614,6 +706,9 @@ namespace SteamWare /// corpo del messaggio public bool mandaEmailNoLog(string _mailFrom, string _mailTo, string _oggetto, string _corpo) { + // chiamo procedura con alelgati nulli... + return mandaEmailNoLog(_mailFrom, _mailTo, _oggetto, _corpo, null); +#if false // sostituisco eventuali a capo nel corpo messaggio... _corpo = _corpo.Replace("\r", "
"); _corpo = _corpo.Replace("\n", "
"); @@ -648,7 +743,8 @@ namespace SteamWare Console.Write("{0}", esmtp.ToString()); logger.lg.scriviLog(string.Format("{0}\r\n full error message\r\n {1}", esmtp.Message, esmtp.ToString()), tipoLog.EXCEPTION); return false; - } + } +#endif } /// /// procedura invio email + scrittura in log!