protected void odsMailConfig_ObjectCreating(object sender, ObjectDataSourceEventArgs e) { if (this.IdSender_ViewState != decimal.MinusOne) { try { MailServerConfigFacade serverFacade = MailServerConfigFacade.GetInstance(); e.ObjectInstance = serverFacade.GetUserByUserId(this.IdSender_ViewState); } catch (Exception ex) { if (ex.GetType() != typeof(ManagedException)) { ManagedException mEx = new ManagedException("Errore nel caricamento della configurazione della mail", "CM007", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); err.loggingAppCode = "WEB_MAIL"; err.objectID = this.Context.Session.SessionID; log.Error(err); info.AddMessage(ex.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR); } else { info.AddMessage(ex.Message, Com.Delta.Messaging.MapperMessages.LivelloMessaggio.ERROR); } } } else { e.ObjectInstance = new MailUser(); } }
protected void ddlManagedAccounts_DataBinding(object sender, EventArgs e) { string username = MySecurityProvider.CurrentPrincipal.MyIdentity.UserName; List <MailUser> l = SessionManager <List <MailUser> > .get(SessionKeys.ACCOUNTS_LIST); MailServerConfigFacade mscf = MailServerConfigFacade.GetInstance(); if (!(l != null && l.Count != 0)) { l = mscf.GetManagedAccountByUser(username).ToList(); if (l == null) { l = new List <MailUser>(); } if (l.Where(x => x.UserId.Equals(-1)).Count() == 0) { l.Insert(0, new MailUser() { UserId = -1, EmailAddress = "" }); } SessionManager <List <MailUser> > .set(SessionKeys.ACCOUNTS_LIST, l); } DropDownList ddl = sender as DropDownList; ddl.DataSource = l; ddl.DataTextField = "EmailAddress"; ddl.DataValueField = "UserId"; UpdAccounts.Update(); }
public HttpResponseMessage AbilitaUsers(string idemail, string itemselector) { FoldersSendersModel model = new FoldersSendersModel(); BackendUserService bus = new BackendUserService(); if (string.IsNullOrEmpty(idemail) && string.IsNullOrEmpty(itemselector)) { model.success = "false"; model.message = "Valori insufficienti nella richiesta"; this.Request.CreateResponse <FoldersSendersModel>(HttpStatusCode.OK, model); } try { // model.FoldersList = listaCartelleNonAbilitate.ToArray(); string[] users = itemselector.Split(';'); var usersAbilitati = bus.GetDipendentiDipartimentoAbilitati(int.Parse(idemail)).Select(z => z.UserId).ToArray(); var ff = Array.ConvertAll(usersAbilitati, x => x.ToString()); var usersda = users.Except(ff); var usersa = ff.Except(users); foreach (string s in usersda) { bus.InsertAbilitazioneEmail(Convert.ToInt32(s), Convert.ToInt32(idemail), 0); } foreach (string s in usersa) { { bus.RemoveAbilitazioneEmail(Convert.ToInt32(s), Convert.ToInt32(idemail)); } } MailUser m = WebMailClientManager.getAccount(); if (m != null) { WebMailClientManager.AccountRemove(); MailServerConfigFacade facade = MailServerConfigFacade.GetInstance(); MailUser account = facade.GetUserByUserId(m.UserId); MailServerFacade serverFacade = MailServerFacade.GetInstance(account); account.Validated = true; WebMailClientManager.SetAccount(account); } model.success = "true"; } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Eccezione nellA ABILITAZIONE UTENTI", "ERR_U005", string.Empty, ex.Message, null); ErrorLogInfo er = new ErrorLogInfo(mEx); er.objectID = idemail.ToString(); log.Error(er); model.success = "false"; model.message = mEx.Message; } else { model.success = "false"; model.message = ex.Message; } } return(this.Request.CreateResponse <FoldersSendersModel>(HttpStatusCode.OK, model)); }
public HttpResponseMessage getMails() { MailModel model = new MailModel(); try { string username = MySecurityProvider.CurrentPrincipal.MyIdentity.UserName; MailServerConfigFacade mailSCF = null; mailSCF = MailServerConfigFacade.GetInstance(); List <CasellaMail> c = new List <CasellaMail>(); List <MailUser> l = SessionManager <List <MailUser> > .get(SessionKeys.ACCOUNTS_LIST); if (l == null || l.Count == 0) { l = mailSCF.GetManagedAccountByUser(username).ToList(); if (l == null) { l = new List <MailUser>(); } if (l.Where(x => x.UserId.Equals(-1)).Count() == 0) { l.Insert(0, new MailUser() { UserId = -1, EmailAddress = "" }); } SessionManager <List <MailUser> > .set(SessionKeys.ACCOUNTS_LIST, l); } if (l != null && l.Count != 0) { // l = mailSCF.GetManagedAccountByUser(username).Distinct().ToList(); foreach (MailUser m in l) { CasellaMail casella = new CasellaMail() { emailAddress = m.Casella, idMail = m.Id.ToString() }; c.Add(casella); } } model.ElencoMails = c; model.Totale = c.Count.ToString(); } catch (Exception ex) { model.success = "false"; model.message = "Errore: " + ex.Message; } return(this.Request.CreateResponse <MailModel>(HttpStatusCode.OK, model)); }
public HttpResponseMessage GetMailSendersByUserMails(int?page, int?start, int?limit) { MailServerConfigFacade mailServerConfigFacade = MailServerConfigFacade.GetInstance(); List <MailUser> users = new List <MailUser>(); UsersMailModel model = new UsersMailModel(); try { string username = MySecurityProvider.CurrentPrincipal.MyIdentity.UserName; MailServerConfigFacade mailSCF = null; mailSCF = MailServerConfigFacade.GetInstance(); users = SessionManager <List <MailUser> > .get(SessionKeys.ACCOUNTS_LIST); if (!(users == null || users.Count == 0)) { users = mailSCF.GetManagedAccountByUser(username).ToList(); if (users == null) { users = new List <MailUser>(); } if (users.Where(x => x.UserId.Equals(-1)).Count() == 0) { users.Insert(0, new MailUser() { UserId = -1, EmailAddress = "" }); } SessionManager <List <MailUser> > .set(SessionKeys.ACCOUNTS_LIST, users); } model.MailUsers = users; } catch (ManagedException bex) { if (bex.GetType() != typeof(ManagedException)) { ManagedException mEx = new ManagedException(bex.Message, "ERR_E002", string.Empty, string.Empty, bex); ErrorLogInfo er = new ErrorLogInfo(mEx); log.Error(er); model.success = "false"; model.message = bex.Message; return(this.Request.CreateResponse <UsersMailModel>(HttpStatusCode.OK, model)); } } return(this.Request.CreateResponse <UsersMailModel>(HttpStatusCode.OK, model)); }
protected void btnLogin_Click(object sender, EventArgs e) { MailServerConfigFacade mailServerConfigFacade = MailServerConfigFacade.GetInstance(); MailServer m = mailServerConfigFacade.LoadServerConfigById(decimal.Parse(ddlServer.SelectedValue)); MailUser account = new MailUser(m); account.Password = txtPassword.Text; account.LoginId = txtName.Text; account.EmailAddress = txtName.Text; account.Dominus = hidDominus.Value; account.Casella = string.Empty; try { IList <MailUser> ctrlAccount = mailServerConfigFacade.GetUserByServerAndUsername(account.Id, account.LoginId); if (ctrlAccount != null) { if (ctrlAccount.Where(acc => acc.LoginId.Equals(account.LoginId) && (acc.Id == m.Id) && acc.IsManaged).Count() != 0) { ((BasePage)this.Page).info.AddError("Questo account è gestito applicativamente. Impossibile effetuare il login da applicazione"); return; } } SetAccount(account); OnStatusChanged(); } catch (ManagedException bex) { if (bex.GetType() != typeof(ManagedException)) { ManagedException mEx = new ManagedException(bex.Message, "ERR_G044", string.Empty, string.Empty, bex); ErrorLogInfo er = new ErrorLogInfo(mEx); log.Error(er); } ((BasePage)this.Page).info.AddError("Connessione al mail server impossibile, controllare le credenziali"); } }
public HttpResponseMessage Comunicazione(FormDataCollection formsValues) { string regexMail = RegexUtils.EMAIL_REGEX.ToString(); TitoliModel model = new TitoliModel(); try { List <ComAllegato> allegati = new List <ComAllegato>(); SendMail.Model.ComunicazioniMapping.Comunicazioni comun = new SendMail.Model.ComunicazioniMapping.Comunicazioni(); string destinatario = formsValues["Destinatario"]; string conoscenza = formsValues["Conoscenza"]; string bcc = formsValues["BCC"]; string oggetto = formsValues["Oggetto"]; string testoMail = formsValues["TestoMail"]; string titolo = formsValues["Titolo"]; string sottotitolo = formsValues["SottoTitolo"]; string userid = formsValues["SenderMail"]; if (SessionManager <Dictionary <string, DTOFileUploadResult> > .exist(SessionKeys.DTO_FILE)) { Dictionary <string, DTOFileUploadResult> dictDto = SessionManager <Dictionary <string, DTOFileUploadResult> > .get(SessionKeys.DTO_FILE); List <DTOFileUploadResult> dto = (List <DTOFileUploadResult>)dictDto.Values.ToList(); foreach (DTOFileUploadResult d in dto) { SendMail.Model.ComunicazioniMapping.ComAllegato allegato = new SendMail.Model.ComunicazioniMapping.ComAllegato(); allegato.AllegatoExt = d.Extension; allegato.AllegatoFile = d.CustomData; allegato.AllegatoName = d.FileName; allegato.AllegatoTpu = ""; allegato.FlgInsProt = AllegatoProtocolloStatus.FALSE; allegato.FlgProtToUpl = AllegatoProtocolloStatus.FALSE; allegati.Add(allegato); } } comun.ComAllegati = allegati; string[] destinatari = destinatario.Split(';'); for (int i = 0; i < destinatari.Length; i++) { var match = Regex.Match(destinatari[i], regexMail, RegexOptions.IgnoreCase); if (!match.Success) { model.success = "false"; model.message = "Attenzione mail destinatario non valida"; return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model)); } } // gestione destinatari ContactsApplicationMapping c = new ContactsApplicationMapping { Mail = destinatario, IdSottotitolo = long.Parse(sottotitolo), IdTitolo = long.Parse(titolo) }; Collection <ContactsApplicationMapping> en = new Collection <ContactsApplicationMapping>(); en.Add(c); if (conoscenza != string.Empty) { string[] conoscenze = conoscenza.Split(';'); for (int i = 0; i < conoscenze.Length; i++) { var match = Regex.Match(conoscenze[i], regexMail, RegexOptions.IgnoreCase); if (!match.Success) { model.success = "false"; model.message = "Attenzione mail conoscenza non valida"; return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model)); } } ContactsApplicationMapping c1 = new ContactsApplicationMapping { Mail = conoscenza, IdSottotitolo = long.Parse(sottotitolo), IdTitolo = long.Parse(titolo) }; Collection <ContactsApplicationMapping> en1 = new Collection <ContactsApplicationMapping>(); en1.Add(c1); comun.SetMailDestinatari(en1, AddresseeType.CC); } if (bcc != string.Empty) { string[] bccs = bcc.Split(';'); for (int i = 0; i < bcc.Length; i++) { var match = Regex.Match(bccs[i], regexMail, RegexOptions.IgnoreCase); if (!match.Success) { model.success = "false"; model.message = "Attenzione mail destinatario nascosto non valido"; return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model)); } } ContactsApplicationMapping c2 = new ContactsApplicationMapping { Mail = bcc, IdSottotitolo = long.Parse(sottotitolo), IdTitolo = long.Parse(titolo) }; Collection <ContactsApplicationMapping> en2 = new Collection <ContactsApplicationMapping>(); en2.Add(c2); comun.SetMailDestinatari(en2, AddresseeType.CCN); } comun.SetMailDestinatari(en, AddresseeType.TO); // gestione body email MailContent content = new MailContent(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); string html = testoMail; HtmlAgilityPack.HtmlNode body = null; if (string.IsNullOrEmpty(html) == false) { doc.LoadHtml(html); doc.OptionAutoCloseOnEnd = true; doc.OptionFixNestedTags = true; body = doc.DocumentNode.Descendants() .Where(n => n.Name.Equals("body", StringComparison.InvariantCultureIgnoreCase)) .FirstOrDefault(); } var ele = new HtmlAgilityPack.HtmlNode(HtmlAgilityPack.HtmlNodeType.Element, doc, 0); ele.Name = "div"; ele.InnerHtml = testoMail; content.MailSubject = oggetto; content.MailText = ele.OuterHtml; // gestione sender MailServerConfigFacade mailSCF = MailServerConfigFacade.GetInstance(); MailUser mailuser = mailSCF.GetUserByUserId(decimal.Parse(userid)); content.MailSender = mailuser.EmailAddress; c.IdTitolo = long.Parse(titolo); c.IdSottotitolo = long.Parse(sottotitolo); comun.UtenteInserimento = MySecurityProvider.CurrentPrincipal.MyIdentity.UserName; comun.MailComunicazione = content; // da scommentare comun.FolderTipo = "O"; comun.FolderId = 2; ComunicazioniService com = new ComunicazioniService(); com.InsertComunicazione(comun); model.success = "true"; SessionManager <Dictionary <string, DTOFileUploadResult> > .del(SessionKeys.DTO_FILE); } catch (Exception ex) { if (ex.GetType() != typeof(ManagedException)) { ManagedException mEx = new ManagedException("Errore invio nuova mail. Dettaglio: " + ex.Message + "StackTrace: " + ((ex.StackTrace != null) ? ex.StackTrace.ToString() : " vuoto "), "ERR317", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); model.success = "false"; model.message = ex.Message; return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model)); } } return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model)); }
public Com.Delta.Mail.Facades.IMailServerConfigFacade getMailServerConfigFacade() { return(MailServerConfigFacade.GetInstance()); }
public HttpResponseMessage AbilitaFolders(string idemail, string itemselector) { FoldersSendersModel model = new FoldersSendersModel(); SendersFoldersService sfs = new SendersFoldersService(); if (string.IsNullOrEmpty(idemail) && string.IsNullOrEmpty(itemselector)) { model.success = "false"; model.message = "Valori insufficienti nella richiesta"; this.Request.CreateResponse <FoldersSendersModel>(HttpStatusCode.OK, model); } try { // model.FoldersList = listaCartelleNonAbilitate.ToArray(); string[] folders = itemselector.Split(';'); var foldersAbilitati = sfs.GetFoldersAbilitatiByIdSender(int.Parse(idemail)).Select(z => z.IdNome).ToArray(); var ff = Array.ConvertAll(foldersAbilitati, x => x.ToString()); var foldersda = folders.Except(ff); var foldersa = ff.Except(folders); foreach (string s in foldersda) { sfs.InsertAbilitazioneFolder(Convert.ToInt32(s), Convert.ToInt32(idemail), 0); } foreach (string s in foldersa) { if (s != "1" && s != "2" && s != "3") { sfs.DeleteAbilitazioneFolder(Convert.ToInt32(s), Convert.ToInt32(idemail)); } } MailUser m = WebMailClientManager.getAccount(); if (m != null) { WebMailClientManager.AccountRemove(); MailServerConfigFacade facade = MailServerConfigFacade.GetInstance(); MailUser account = facade.GetUserByUserId(m.UserId); MailServerFacade serverFacade = MailServerFacade.GetInstance(account); account.Validated = true; WebMailClientManager.SetAccount(account); } model.success = "true"; MailLocalService mailLocalService = new MailLocalService(); CacheManager <List <ActiveUp.Net.Common.DeltaExt.Action> > .set(CacheKeys.FOLDERS_ACTIONS, mailLocalService.GetFolderDestinationForAction()); } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Eccezione nella lettura delle cartelle", "ERR_F005", string.Empty, ex.Message, null); ErrorLogInfo er = new ErrorLogInfo(mEx); er.objectID = idemail.ToString(); log.Error(er); model.success = "false"; model.message = mEx.Message; } else { model.success = "false"; model.message = ex.Message; } } return(this.Request.CreateResponse <FoldersSendersModel>(HttpStatusCode.OK, model)); }
public static void Send(string mail, int maxNrMail) { Console.WriteLine("Invio mail"); MailMessage email = new MailMessage(); List <SendMail.Model.ComunicazioniMapping.Comunicazioni> listComunicazioni = null; ComunicazioniService service = new ComunicazioniService(); listComunicazioni = (List <SendMail.Model.ComunicazioniMapping.Comunicazioni>)service.LoadComunicazioniDaInviare(CANALE_INVIO, 0, maxNrMail, mail); if (listComunicazioni == null || listComunicazioni.Count == 0) { _log.Info(new MailLogInfo(APP_CODE, "", "BATCH", mail, "Nessuna comunicazione da inviare")); return; } #if TEST // listComunicazioni = listComunicazioni.Where(c => c.IdComunicazione == 54373).ToList(); #endif Console.WriteLine("Trovate {0} comunicazioni", listComunicazioni.Count); _log.Info(new MailLogInfo(APP_CODE, "", "BACTH", mail, string.Format("Trovate {0} comunicazioni", listComunicazioni.Count))); List <String> mails = null; var accs = from c in listComunicazioni where c.MailComunicazione != null let mc = c.MailComunicazione where !String.IsNullOrEmpty(mc.MailSender) select mc.MailSender; if (accs != null && accs.Count() != 0) { mails = accs.Distinct().ToList(); } IList <MailUser> mUs = null; if (mails != null) { MailAccountService accS = new MailAccountService(); mUs = accS.GetUsersByMails(mails); } if (mUs == null) { ManagedException mEx = new ManagedException("Nessun account mappato per invio mail", "SND_ERR_011", string.Empty, string.Empty, null); ErrorLogInfo err = new ErrorLogInfo(mEx); _log.Error(err); return; } foreach (SendMail.Model.ComunicazioniMapping.Comunicazioni comun in listComunicazioni) { Console.WriteLine("Id comunicazione: {0}", comun.IdComunicazione); SendMail.Model.ComunicazioniMapping.ComFlusso nuovoFlusso = null; IOrderedEnumerable <SendMail.Model.ComunicazioniMapping.ComFlusso> flusso = comun.ComFlussi[CANALE_INVIO].OrderBy(f => !f.DataOperazione.HasValue).ThenBy(f => f.DataOperazione); if (flusso.Last().StatoComunicazioneOld == MailStatus.SEND_AGAIN) { nuovoFlusso = flusso.Last(); } else { nuovoFlusso = new SendMail.Model.ComunicazioniMapping.ComFlusso() { Canale = CANALE_INVIO, RefIdComunicazione = comun.IdComunicazione, StatoComunicazioneOld = flusso.Last().StatoComunicazioneNew, StatoComunicazioneNew = MailStatus.UNKNOWN, UtenteOperazione = flusso.Last().UtenteOperazione }; comun.ComFlussi[CANALE_INVIO].Add(nuovoFlusso); } if (!comun.IsValid) { nuovoFlusso.StatoComunicazioneNew = MailStatus.ERROR; UpdateFlusso(comun); continue; } MailUser us = mUs.SingleOrDefault(x => x.EmailAddress == comun.MailComunicazione.MailSender); if (us == null) { nuovoFlusso.StatoComunicazioneNew = MailStatus.CANCELLED; UpdateFlusso(comun); continue; } List <SendMail.Model.ComunicazioniMapping.ComAllegato> allegatiList = (List <SendMail.Model.ComunicazioniMapping.ComAllegato>)comun.ComAllegati; try { foreach (SendMail.Model.ComunicazioniMapping.ComAllegato allegato in allegatiList) { try { switch (allegato.AllegatoExt) { case "XSL": case "xsl": System.IO.MemoryStream sXML = new System.IO.MemoryStream(allegato.AllegatoFile); XmlDocument xml = new XmlDocument(); xml.Load(sXML); string xslUri = System.IO.Path.Combine(ConfigurationManager.AppSettings.Get("pathFolderTpu"), allegato.AllegatoTpu); string[] separator = new string[1] { ".tpu" }; string[] appo = xslUri.Split(separator, StringSplitOptions.RemoveEmptyEntries); XmlDocument xsl = new XmlDocument(); xsl.Load(appo[0].Trim()); // modificato per usare itextsharp PdfFormatterITEXT fo = FormatterProvider.formatDocumentitext("PDF"); System.IO.MemoryStream mPdf = fo.formatData(xml, xsl); // fine modifica IDictionary <string, string> d = new Dictionary <string, string>(); d.Add("subject", "VERIFICA ABITAZIONE"); d.Add("author", "ROMA CAPITALE"); d.Add("creator", "Certificati Online"); byte[] bdoc = fo.SetMetadati(mPdf, d); allegato.AllegatoFile = bdoc; allegato.AllegatoExt = "PDF"; break; default: break; } } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella generazione del pdf", "SEN_012", string.Empty, string.Empty, ex.InnerException); mEx.addEnanchedInfosTag("REQUEST", new XElement("Mail", new XAttribute("IdComunicazione", comun.IdComunicazione), new XElement("Status", nuovoFlusso.StatoComunicazioneNew.ToString()), new XElement("IdMail", (comun.MailComunicazione.IdMail != null) ? comun.MailComunicazione.IdMail.ToString():" vuoto ")).ToString()); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = (comun.UniqueId != null) ? comun.UniqueId : comun.IdComunicazione.ToString(); _log.Error(err); throw mEx; } else { throw; } } } } catch { nuovoFlusso.StatoComunicazioneNew = MailStatus.ERROR; UpdateFlusso(comun); continue; } try { service.UpdateAllegati(CANALE_INVIO, comun); } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore aggiornamento della mail", "SEN_002", string.Empty, string.Empty, ex.InnerException); mEx.addEnanchedInfosTag("REQUEST", new XElement("Mail", new XAttribute("IdMail", comun.IdComunicazione), new XElement("Status", nuovoFlusso.StatoComunicazioneNew.ToString())).ToString()); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = (comun.UniqueId != null) ? comun.UniqueId : comun.IdComunicazione.ToString(); _log.Error(err); } } try { email = ComunicazioniExtensionMethods.ConvertToEmail(comun); if (null == email) { throw new ArgumentNullException("email non creata"); } //carica le immagini HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(email.Body); var imgs = from img in htmlDoc.DocumentNode.Descendants("img") where img.Attributes["src"].Value.StartsWith("file:///") select img; if (imgs.Count() > 0) { foreach (var img in imgs) { string rootPath = ConfigurationManager.AppSettings.Get("pathFolderTpu"); string pathImg = Path.Combine(rootPath, img.Attributes["src"].Value.Substring(8)); string ext = Path.GetExtension(pathImg).Substring(1); byte[] imgBytes = File.ReadAllBytes(pathImg); img.Attributes["src"].Value = "data:image/" + ext + ";base64," + Convert.ToBase64String(imgBytes); } using (Stream ms = new MemoryStream()) { htmlDoc.Save(ms, new UTF8Encoding(false)); ms.Position = 0; byte[] buffer = new byte[ms.Length]; ms.Read(buffer, 0, (int)ms.Length); email.Body = new UTF8Encoding(false).GetString(buffer); service.UpdateMailBody(comun.MailComunicazione.IdMail.Value, email.Body); } } foreach (ComAllegato t in comun.ComAllegati) { email.Attachments.Add(ComunicazioniExtensionMethods.ConvertToAttachment(t)); } } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione della mail per il metabus", "SEN_003", string.Empty, string.Empty, ex.InnerException); mEx.addEnanchedInfosTag("REQUEST", new XElement("Mail", new XAttribute("IdMail", comun.MailComunicazione.IdMail)).ToString()); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = (comun.UniqueId != null) ? comun.UniqueId : comun.IdComunicazione.ToString(); _log.Error(err); } nuovoFlusso.StatoComunicazioneNew = MailStatus.ERROR; UpdateFlusso(comun); continue; } try { MailUser user = MailServerConfigFacade.GetInstance().GetManagedUserByAccount(email.From.Address); System.Net.Mail.SmtpClient smtpMail = new System.Net.Mail.SmtpClient(); smtpMail = new System.Net.Mail.SmtpClient(user.OutgoingServer, user.PortOutgoingServer); smtpMail.EnableSsl = user.IsOutgoingSecureConnection; smtpMail.DeliveryMethod = SmtpDeliveryMethod.Network; smtpMail.UseDefaultCredentials = false; if (user.LoginId != null && user.Password != null && user.LoginId.Length > 0) { smtpMail.Credentials = new NetworkCredential(user.LoginId, user.Password); } smtpMail.Send(email); nuovoFlusso.StatoComunicazioneNew = MailStatus.SENT; UpdateFlusso(comun); } catch (Exception ex) { XElement details = new XElement("comunicazione", new XAttribute("uniqueId", comun.UniqueId)); if (ex != null) { System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(Exception)); MemoryStream ms = new MemoryStream(); ser.Serialize(ms, ex); ms.Seek(0, SeekOrigin.Begin); details.Add(XElement.Load(XmlReader.Create(ms))); } if (!ex.GetType().Equals(typeof(ManagedException))) { //TASK: Allineamento log - Ciro ManagedException mEx = new ManagedException(String.Format("Errore: {0}", ex.Message), "SND_ERR_107", string.Empty, string.Empty, ex.InnerException); mEx.addEnanchedInfosTag("REQUEST", new XElement("Mail", new XAttribute("IdMail", comun.IdComunicazione)).ToString()); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = (comun.UniqueId != null) ? comun.UniqueId : comun.IdComunicazione.ToString(); _log.Error(err); } nuovoFlusso.StatoComunicazioneNew = MailStatus.SEND_AGAIN; UpdateFlusso(comun); } } }