private void SendMailNotification(Survey survey, SurveyUser surveyUser, SurveyCollector collector, int?notificationID) { Notification notification = PXSelect <Notification, Where <Notification.notificationID, Equal <Required <Notification.notificationID> > > > .Select(this, notificationID); /* * notification.RefNoteID = collector.NoteID.ToString(); */ //var sent = false; var emailGenerator = TemplateNotificationGenerator.Create(collector, notification); emailGenerator.LinkToEntity = true; emailGenerator.To = surveyUser.Email; emailGenerator.ContactID = surveyUser.ContactID; var generator = new SurveyGenerator(); var url = generator.GetUrl(survey, collector.Token, null); emailGenerator.Body = emailGenerator.Body.Replace("((Collector.URL))", url); //sender.MailAccountId = notification.NFrom ?? MailAccountManager.DefaultMailAccountID; emailGenerator.RefNoteID = collector.NoteID; //sender.Subject = //bool asAttachment = false; //if (asAttachment) { //if (!string.IsNullOrEmpty(message)) { // sender.AddAttachment("HeaderContent.json", Encoding.UTF8.GetBytes(message)); //} //} else { //sender.Body = message; //sender.BodyFormat = PX.Objects.CS.NotificationFormat.Html; //} //foreach (Guid? attachment in (IEnumerable<Guid?>)attachments) { // if (attachment.HasValue) // notificationGenerator.AddAttachmentLink(attachment.Value); //} var emails = emailGenerator.Send(); }
private static void AddEmailActivity(AutoRemindCaseInfo CurrentCase, Notification rowNotiication) { bool sent = false; string sError = "Failed to send E-mail."; try { var sender = TemplateNotificationGenerator.Create(CurrentCase, rowNotiication.NotificationID.Value); sender.MailAccountId = (rowNotiication.NFrom.HasValue) ? rowNotiication.NFrom.Value : PX.Data.EP.MailAccountManager.DefaultMailAccountID; sender.RefNoteID = CurrentCase.NoteID; sender.To = CurrentCase.EMail; sender.Owner = CurrentCase.OwnerID; sent |= sender.Send().Any(); } catch (Exception Err) { sent = false; sError = Err.Message; } if (!sent) { throw new PXException(sError); } }
private void SendMassMail(int?accountId, string mailTo, string mailCc, string mailBcc, IEnumerable <Recipient> recievers, bool linkToEntity) { PXGraph proc = new PXGraph(); EntityHelper entityHelper = new EntityHelper(proc); foreach (Recipient item in recievers) { var entity = item.Entity; PXCache cache = proc.Caches[entity.GetType()]; cache.SetStatus(entity, PXEntryStatus.Notchanged); var id = entityHelper.GetEntityNoteID(entity, true); var sender = TemplateNotificationGenerator.Create(entity); sender.MailAccountId = accountId ?? MailAccountManager.DefaultMailAccountID; sender.To = mailTo; sender.Cc = mailCc; sender.Bcc = mailBcc; sender.Body = MassMails.Current.MailContent ?? string.Empty; sender.Subject = MassMails.Current.MailSubject; sender.BodyFormat = item.Format; sender.AttachmentsID = MassMails.Current.NoteID; sender.LinkToEntity = linkToEntity; var messages = sender.Send(); foreach (CRSMEmail message in messages) { var log = (CRMassMailMessage)SendedMessages.Cache.CreateInstance(); log.MassMailID = MassMails.Current.MassMailID; log.MessageID = message.ImcUID; SendedMessages.Insert(log); } } }
private void SendMassMail(int?accountId, string mailTo, string mailCc, string mailBcc, IEnumerable <Recipient> recievers, bool linkToEntity) { foreach (Recipient item in recievers) { var entity = item.Entity; var sender = TemplateNotificationGenerator.Create(entity); sender.MailAccountId = accountId ?? MailAccountManager.DefaultMailAccountID; sender.To = mailTo ?? string.Empty; sender.Cc = mailCc ?? string.Empty; sender.Bcc = mailBcc ?? string.Empty; sender.Body = MassMails.Current.MailContent ?? string.Empty; sender.Subject = MassMails.Current.MailSubject; sender.BodyFormat = item.Format; sender.AttachmentsID = MassMails.Current.NoteID; sender.LinkToEntity = linkToEntity; var messages = sender.Send(); foreach (EPActivity message in messages) { var log = (CRMassMailMessage)SendedMessages.Cache.CreateInstance(); log.MassMailID = MassMails.Current.MassMailID; log.MessageID = message.ImcUID; SendedMessages.Insert(log); } } }
protected override void SendUserNotification(int?accountId, Notification notification) { var gen = TemplateNotificationGenerator.Create(this.UserList.Current, notification); gen.MailAccountId = accountId; gen.To = this.UserList.Current.Email; gen.Body = gen.Body.Replace("((UserList.Password))", this.UserList.Current.Password); gen.LinkToEntity = true; gen.Send(); }
public void SendUserNotification(int?accountId, Notification notification, Action <int?, Notification> del) { var gen = TemplateNotificationGenerator.Create(Base, Base.UserList.Current, notification); gen.MailAccountId = accountId; gen.To = Base.UserList.Current.Email; gen.LinkToEntity = true; gen.Body = gen.Body.Replace("((UserList.Password))", Base.UserList.Current.Password); gen.Send(); }
private static void SendMassMail(int?accountId, string mailTo, string mailCc, string mailBcc, IEnumerable <Recipient> recievers, bool linkToEntity, CRMassMailMaint graph, CRMassMail current, bool previewMessage = false) { PXGraph proc = new PXGraph(); EntityHelper entityHelper = new EntityHelper(proc); foreach (Recipient item in recievers) { var entity = item.Entity; PXCache cache = proc.Caches[entity.GetType()]; cache.SetStatus(entity, PXEntryStatus.Notchanged); var id = entityHelper.GetEntityNoteID(entity, true); var sender = TemplateNotificationGenerator.Create(item.Contact); sender.MailAccountId = accountId ?? MailAccountManager.DefaultMailAccountID; sender.To = mailTo; sender.Cc = mailCc; sender.Bcc = mailBcc; sender.Body = graph.MassMails.Current.MailContent ?? string.Empty; sender.Subject = graph.MassMails.Current.MailSubject; sender.BodyFormat = item.Format; sender.AttachmentsID = graph.MassMails.Current.NoteID; if (linkToEntity) { sender.RefNoteID = id; sender.BAccountID = item.Contact.BAccountID; sender.ContactID = item.Contact.ContactID; } var messages = sender.Send(); foreach (CRSMEmail message in messages) { var log = (CRMassMailMessage)graph.SendedMessages.Cache.CreateInstance(); log.MassMailID = graph.MassMails.Current.MassMailID; log.MessageID = message.ImcUID; graph.SendedMessages.Insert(log); } } if (!previewMessage) { graph.MassMails.Current.Status = CRMassMailStatusesAttribute.Send; graph.MassMails.Current.SentDateTime = DateTime.Now; graph.MassMails.Update(graph.MassMails.Current); } graph.Save.Press(); }
public TemplateNotificationGenerator GetSender(CRMassMail massMail) { var sender = TemplateNotificationGenerator.Create(Contact); sender.MailAccountId = massMail.MailAccountID ?? MailAccountManager.DefaultMailAccountID; sender.To = massMail.MailTo; sender.Cc = massMail.MailCc; sender.Bcc = massMail.MailBcc; sender.Body = massMail.MailContent ?? string.Empty; sender.Subject = massMail.MailSubject; sender.AttachmentsID = massMail.NoteID; sender.BAccountID = BAccountID; sender.BodyFormat = Format; sender.RefNoteID = RefNoteID; sender.ContactID = ContactID; sender.DocumentNoteID = DocumentNoteID; return(sender); }
private void SendEmail(NotificationRecipient notificationRecipient, NotificationSourceModel notificationSourceModel, ComplianceDocument complianceDocument) { var email = RecipientEmailDataProvider .GetRecipientEmail(notificationRecipient, notificationSourceModel.VendorId); if (email != null) { var report = GetReportInAppropriateFormat(notificationRecipient.Format, notificationSourceModel, complianceDocument); var sender = TemplateNotificationGenerator.Create(complianceDocument, notificationSourceModel.NotificationSource.NotificationID); sender.MailAccountId = notificationSourceModel.NotificationSource.EMailAccountID; sender.RefNoteID = complianceDocument.NoteID; sender.To = email; sender.AddAttachmentLink(report.ReportFileInfo.UID.GetValueOrDefault()); sender.Send(); UpdateLienWaiverProcessedStatus(complianceDocument); } }
private static void AddEmailActivity(SurveyContactInfo CurrentCase) { bool sent = false; string sError = "Failed to send E-mail."; try { var sender = TemplateNotificationGenerator.Create(CurrentCase, CurrentCase.NotificationMapID.Value); sender.MailAccountId = (CurrentCase.NotificationNFrom.HasValue) ? CurrentCase.NotificationNFrom.Value : PX.Data.EP.MailAccountManager.DefaultMailAccountID; sender.To = CurrentCase.EMail; sent |= sender.Send().Any(); } catch (Exception Err) { sent = false; sError = Err.Message; } if (!sent) { throw new PXException(sError); } }
private static void Send(AppointmentEntry graphAppointmentEntry, PXCache sourceCache, Guid setupID, int?branchID, IDictionary <string, string> reportParams, IList <Guid?> attachments = null) { string emailToAccounts, emailBCCAccounts; emailToAccounts = string.Empty; emailBCCAccounts = string.Empty; FSAppointment fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current; Guid?refNoteId = fsAppointmentRow.NoteID; Guid?parentNoteId = null; string srvOrdType = fsAppointmentRow.SrvOrdType; NotificationSource source = GetSource(graphAppointmentEntry, srvOrdType, setupID, branchID); if (source == null) { //The current Notification Type (MailingID) is not configured for this Service Order Type return; } var accountId = source.EMailAccountID ?? DefaultEMailAccountId; if (accountId == null) { sourceCache.RaiseExceptionHandling <FSAppointment.srvOrdType>( sourceCache.Current, ((FSAppointment)sourceCache.Current).SrvOrdType, new PXSetPropertyException( TX.Warning.DEFAULT_EMAIL_NOT_CONFIGURED, PXErrorLevel.Warning)); } RecipientList recipients = GetRecipients(graphAppointmentEntry, source.SourceID, accountId); if (recipients == null || recipients.Count() == 0) { return; } GetsRecipientsFields(recipients, ref emailToAccounts, ref emailBCCAccounts); var sent = false; if (source.ReportID != null) { var sender = new ReportNotificationGenerator(source.ReportID) { MailAccountId = accountId, Format = source.Format, AdditionalRecipents = recipients, Parameters = reportParams, NotificationID = source.NotificationID }; sent |= sender.Send().Any(); } else if (source.NotificationID != null) { var sender = TemplateNotificationGenerator.Create(fsAppointmentRow, (int)source.NotificationID); if (source.EMailAccountID != null) { sender.MailAccountId = accountId; } string notificationBody = sender.Body; FSAppointment.ReplaceWildCards(graphAppointmentEntry, ref notificationBody, fsAppointmentRow); sender.Body = notificationBody; sender.BodyFormat = source.Format; sender.RefNoteID = refNoteId; sender.ParentNoteID = parentNoteId; sender.To = emailToAccounts; sender.Bcc = emailBCCAccounts; if (attachments != null) { foreach (var attachment in attachments) { if (attachment != null) { sender.AddAttachmentLink(attachment.Value); } } } sent |= sender.Send().Any(); } if (!sent) { throw new PXException(PX.Objects.CR.Messages.EmailNotificationError); } }