public BackEndUserMailUserMapping(ActiveUp.Net.Mail.DeltaExt.MailUser mailAccount, int accessLevel) { if (mailAccount != null) { this.Casella = mailAccount.Casella; this.DisplayName = mailAccount.DisplayName; this.Dominus = mailAccount.Dominus; this.EmailAddress = mailAccount.EmailAddress; this.Id = this.MailSenderId = mailAccount.Id; this.IncomingProtocol = mailAccount.IncomingProtocol; this.IncomingServer = mailAccount.IncomingServer; this.IsIncomeSecureConnection = mailAccount.IsIncomeSecureConnection; this.FlgManaged = mailAccount.FlgManaged; this.FlgManagedInsert = (mailAccount.FlgManaged > 0) ? true : false; this.IsOutgoingSecureConnection = mailAccount.IsOutgoingSecureConnection; this.IsOutgoingWithAuthentication = mailAccount.IsOutgoingWithAuthentication; this.IsPec = mailAccount.IsPec; this.OutgoingServer = mailAccount.OutgoingServer; this.Password = mailAccount.Password; this.PortIncomingChecked = mailAccount.PortIncomingChecked; this.PortIncomingServer = mailAccount.PortIncomingServer; this.PortOutgoingChecked = mailAccount.PortOutgoingChecked; this.PortOutgoingServer = mailAccount.PortOutgoingServer; this.UserId = mailAccount.UserId; this.MailAccessLevel = accessLevel; } }
/// <summary> /// Metodo per il caricamento del messaggio di reply to all /// </summary> /// <returns></returns> private bool LoadMessageReplyAll() { ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = WebMailClientManager.getAccount(); if (mailUser == null) { onAccountInvalid(); return(false); } Message msg = GetCurrentMessage(); if (msg == null) { onMessageInvalid(); return(false); } if (selectEmail(msg.To).Contains(mailUser.EmailAddress)) { msg.To = (AddressCollection)msg.To.Where(x => !x.Email.Equals(mailUser.EmailAddress)).ToList(); } msg.To.Add(msg.From); if (selectEmail(msg.Cc).Contains(mailUser.EmailAddress)) { msg.Cc = (AddressCollection)msg.Cc.Where(x => !x.Email.Equals(mailUser.EmailAddress)).ToList(); } msg.Bcc.Clear(); msg.From = new Address(mailUser.EmailAddress, mailUser.DisplayName); msg.ReplyTo = new Address(); msg.Subject = String.Concat("Re:", msg.Subject); ToTextBox.ReadOnly = true; SubjectTextBox.ReadOnly = true; CCTextBox.ReadOnly = true; return(true); }
/// <summary> /// Metodo per il caricamento del messaggio di reply /// </summary> /// <returns></returns> private bool LoadMessageReply() { ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = WebMailClientManager.getAccount(); if (mailUser == null) { onAccountInvalid(); return(false); } Message msg = GetCurrentMessage(); if (msg == null) { onMessageInvalid(); return(false); } msg.To.Clear(); msg.To.Add(msg.From); msg.From = new Address(mailUser.EmailAddress, mailUser.DisplayName); msg.ReplyTo = new Address(); msg.Bcc.Clear(); msg.Subject = String.Concat("Re:", msg.Subject); ToTextBox.ReadOnly = true; SubjectTextBox.ReadOnly = true; return(true); }
/// <summary> /// Metodo per il caricamento del messaggio di send /// </summary> /// <returns></returns> private bool LoadMessageSend() { ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = WebMailClientManager.getAccount(); if (mailUser == null) { onAccountInvalid(); return(false); } Message msg = CreateNewMessage(); if (msg == null) { onMessageInvalid(); return(false); } msg.From = new Address(mailUser.EmailAddress, mailUser.DisplayName); msg.ReplyTo = new Address(); return(true); }
public void Update(ActiveUp.Net.Mail.DeltaExt.MailUser u, ActiveUp.Net.Mail.Message m) { using (var dbcontext = new FAXPECContext()) { try { MAIL_INBOX inbox = dbcontext.MAIL_INBOX.Where(x => x.ID_MAIL == int.Parse(m.Uid) && x.MAIL_ACCOUNT.ToUpper() == u.EmailAddress.ToUpper()).First(); inbox = DaoSQLServerDBHelper.MapToMailInBox(u, m); dbcontext.SaveChanges(); } catch (Exception e) { if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nel metodo Update(ActiveUp.Net.Mail.DeltaExt.MailUser u, ActiveUp.Net.Mail.Message m) Dettaglio: " + e.Message, "E015", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); _log.Error(err); } } } }
/// <summary> /// Metodo per il caricamento del messaggio di forward /// </summary> /// <returns></returns> private bool LoadMessageForward() { ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = WebMailClientManager.getAccount(); if (mailUser == null) { onAccountInvalid(); return(false); } Message msg = GetCurrentMessage(); if (msg == null) { onMessageInvalid(); return(false); } msg.From = new Address(mailUser.EmailAddress, mailUser.DisplayName); msg.To.Clear(); msg.Cc.Clear(); msg.Bcc.Clear(); msg.Subject = String.Concat("Fw:", msg.Subject); return(true); }
public void Insert(ActiveUp.Net.Mail.DeltaExt.MailUser user, ActiveUp.Net.Mail.Message m) { using (var dbcontext = new FAXPECContext()) { using (var dbTransaction = dbcontext.Database.BeginTransaction()) { MAIL_INBOX c = AutoMapperConfiguration.MapToMailInBoxDto(user, m); int rows = 0; try { dbcontext.MAIL_INBOX.Add(c); dbcontext.SaveChanges(); var mailinboxnew = dbcontext.MAIL_INBOX.Where(z => z.MAIL_SERVER_ID == c.MAIL_SERVER_ID).First(); int newid = (int)mailinboxnew.ID_MAIL; MailStatus newStatus = MailStatus.SCARICATA; MailStatus oldStatus = MailStatus.UNKNOWN; if (String.IsNullOrEmpty(m.MessageId)) { newStatus = MailStatus.SCARICATA_INCOMPLETA; } string os = ((int)oldStatus).ToString(); string ns = ((int)newStatus).ToString(); MAIL_INBOX_FLUSSO f = AutoMapperConfiguration.MapToMailInboxFlussoDto(newid, os, ns, m.ReceivedDate, "SYSTEM"); dbcontext.MAIL_INBOX_FLUSSO.Add(f); rows = dbcontext.SaveChanges(); dbTransaction.Commit(); } catch (SqlException oEx) { if (dbTransaction.UnderlyingTransaction.Connection != null) { dbTransaction.Rollback(); } ManagedException mEx = mEx = new ManagedException("Errore nell'inserimento su DB della mail con uid: " + m.Uid + " della casella " + user.EmailAddress, "ERR_INS_ML_001", string.Empty, string.Empty, oEx.InnerException); mEx.addEnanchedInfosTag("DETTAGLIO", "Classe: MailMessageDaoOracleDb " + "Metodo: Insert(MailUser user, Message m) " + "Dettaglio: Salvataggio della mail su Oracle DB " + "User Login: "******" Mail UID: " + m.Uid); ErrorLogInfo err; if (oEx.Message.StartsWith("ORA-00001", StringComparison.InvariantCultureIgnoreCase)) { mEx.CodiceEccezione = "WRN_INS_ML_001"; err = new ErrorLogInfo(mEx); _log.Warn(err); } else { err = new ErrorLogInfo(mEx); _log.Error(err); } if (dbTransaction.UnderlyingTransaction.Connection != null) { dbTransaction.Rollback(); } throw mEx; } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException(ex.Message, "ERR_COM_006", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); _log.Error(err); } if (dbTransaction.UnderlyingTransaction.Connection != null) { dbTransaction.Rollback(); } throw; } } } }
protected void Button1_Click(object sender, EventArgs e) { try { Message msg; ComunicazioniService comunicazioniService = new ComunicazioniService(); if (MailMessageComposer.CurrentSendMailExist()) { msg = MailMessageComposer.CurrentSendMailGet(); } else { msg = new Message(); } msg.Subject = SubjectTextBox.Text; if (String.IsNullOrEmpty(ToTextBox.Text.Trim()) && String.IsNullOrEmpty(CCTextBox.Text.Trim()) && String.IsNullOrEmpty(BCCTextBox.Text.Trim())) { ErrorLabel.Text = "Inserire almeno un destinatario"; ErrorLabel.Visible = true; return; } msg.To.Clear(); msg.Cc.Clear(); msg.Bcc.Clear(); this.addEmailsTo(ToTextBox.Text, msg); this.addEmailsCc(CCTextBox.Text, msg); this.addEmailCcn(BCCTextBox.Text, msg); msg.Date = System.DateTime.Now; //mantengo il vecchio testo perché in caso di ErrorEventArgs lo devo ripristinare bodyBag = msg.BodyHtml.Text; SendMail.Model.BodyChunk bb = new SendMail.Model.BodyChunk(); string txt = BodyTextBox.Text; string[] lst = txt.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string l in lst) { bb.Line.Add(l); } //inserisco il testo libero in testa a quello preformattato HtmlNode newNode = null; if (bb.Line.Count != 0) { newNode = HtmlNode.CreateNode(bb.getAsHtml()); } HtmlDocument d = new HtmlDocument(); if (!String.IsNullOrEmpty(PreformattedBody.Text)) { d.LoadHtml(PreformattedBody.Text); } if (newNode != null) { if (d.DocumentNode.Descendants().Count() != 0) { HtmlNode root = d.DocumentNode.Descendants().SingleOrDefault(x => x.Name.Equals("body", StringComparison.InvariantCultureIgnoreCase)); if (root == null) { root = d.DocumentNode.Descendants().FirstOrDefault(x => x.NodeType == HtmlNodeType.Element); } if (root != null) { root.PrependChild(newNode); } else { d.DocumentNode.PrependChild(newNode); } } else { d.DocumentNode.PrependChild(newNode); } } msg.BodyHtml.Text = d.DocumentNode.InnerHtml; //se non sono inclusi gli allegati originali if (MailEditabile == true && cbIncludiAllegati.Checked == false) { for (int i = 0; i < msg.Attachments.Count; i++) { //rimuovo gli allegati originali if (msg.Attachments[i].ParentMessage != null) { msg.Attachments.RemoveAt(i); } } } foreach (MimePart mm in msg.Attachments) { if (mm.BinaryContent == null || mm.BinaryContent.Length < 10) { if (!String.IsNullOrEmpty(mm.ContentId)) { string idAttach = mm.ContentId.Trim(new char[] { '<', '>' }); long idAtt = -1; if (long.TryParse(idAttach, out idAtt)) { ComAllegato all = comunicazioniService .LoadAllegatoComunicazioneById(long.Parse(idAttach)); mm.BinaryContent = all.AllegatoFile; } } } } switch (CurrentAction) { case MailActions.REPLY_TO: case MailActions.REPLY_ALL: case MailActions.RE_SEND: case MailActions.FORWARD: msg.InReplyTo = msg.Id.ToString(); break; } ActiveUp.Net.Mail.DeltaExt.MailUser mailUser = null; if (WebMailClientManager.AccountExist()) { mailUser = WebMailClientManager.getAccount(); } if (mailUser != null) { MailServerFacade f = MailServerFacade.GetInstance(mailUser); if (mailUser.IsManaged) { try { SendMail.Model.ComunicazioniMapping.Comunicazioni c = new SendMail.Model.ComunicazioniMapping.Comunicazioni( SendMail.Model.TipoCanale.MAIL, this.SottoTitolo, msg, MySecurityProvider.CurrentPrincipal.MyIdentity.UserName, 2, "O"); if (c.MailComunicazione.MailRefs != null && c.MailComunicazione.MailRefs.Count != 0) { c.RubricaEntitaUsed = (from cont in c.MailComunicazione.MailRefs select new SendMail.Model.ComunicazioniMapping.RubrEntitaUsed { Mail = cont.MailDestinatario, TipoContatto = cont.TipoRef }).ToList(); } comunicazioniService.InsertComunicazione(c); } catch (Exception ex) { ManagedException mex = new ManagedException("Errore nel salvataggio della mail", "MAIL_CMP_002", "", ex.StackTrace, ex); ErrorLog err = new ErrorLog(mex); _log.Error(err); ErrorLabel.Text = "Errore nell'invio del messaggio"; ErrorLabel.Visible = true; return; } } else { f.sendMail(msg); } (this.Page as BasePage).info.AddInfo("Il messaggio e' stato spedito correttamente"); MailMessageComposer.CurrentSendMailClear(); onMailSent(); } else { ((BasePage)this.Page).info.AddInfo("Account inesistente."); } } catch (Exception ex) { if (ex.GetType() != typeof(ManagedException)) { _log.Error(new Com.Delta.Logging.Errors.ErrorLog(new ManagedException(ex.Message, "FAC_007", string.Empty, string.Empty, ex))); } //_log.Error(new Com.Delta.Logging.Errors.ErrorLog("FAC_007", ex, string.Empty, string.Empty, string.Empty)); MailMessageComposer.CurrentSendMailGet().BodyHtml.Text = bodyBag; ErrorLabel.Visible = true; ErrorLabel.Text = ex.Message; return; } Label5.Visible = true; }