public void SendMailFromModuleNotification(string istanceIdentifier, int idUser, string moduleCode, Notification.Domain.dtoModuleNotificationMessage message) { IstanceConfig istance = Config.GetIstanceConfiguration(istanceIdentifier); SmtpServiceConfig cfg = GetSmtpSettings(istanceIdentifier); if (cfg != null && istance != null) { using (ISession session = lm.Comol.Core.Data.SessionDispatcher.NewSession(istance.ConnectionString)) { if (session != null) { using (InternalMailService service = new InternalMailService(cfg, istance, session)) { Boolean result = false; String messagePath = service.GetAttachmentsFullPath(istance.AttachmentUploadPath, message.AttachmentPath); try { result = service.SendMail(idUser, moduleCode, message, (message.MailSettings.IsBodyHtml), messagePath, message.AttachmentSavedPath); } catch (Exception ex) { ErrorHandler.addMessageToPoisonQueue(ex, message); } } } else { ErrorHandler.addMessageToPoisonQueue(message); } } } }
private void InternalSendMail(string istanceIdentifier, int idUser, int idCommunity, string moduleCode, SmtpServiceConfig cfg, Message message, string attachmentPath = "", bool saveMessage = false, string attachmentSavedPath = "") { IstanceConfig istance = Config.GetIstanceConfiguration(istanceIdentifier); if (cfg != null && istance != null) { using (ISession session = lm.Comol.Core.Data.SessionDispatcher.NewSession(istance.ConnectionString)) { if (session != null) { using (InternalMailService service = new InternalMailService(cfg, istance, session)) { Boolean result = false; String messagePath = service.GetAttachmentsFullPath(istance.AttachmentUploadPath, attachmentPath); try { result = service.SendMail(idUser, idCommunity, moduleCode, message, (message.Settings.IsBodyHtml), messagePath, saveMessage, attachmentSavedPath); } catch (Exception ex) { ErrorHandler.addMessageToPoisonQueue(ex, message); } } } else { ErrorHandler.addMessageToPoisonQueue(message); } } } }