Skip to main content

Hi,

I’m using this link to https://asiablog.acumatica.com/2017/05/sending-notification-template-from.html no send a custom notification, but for some reason is not working, the sender.send() return an empty list. I’m using a custom graph and DAC.  The form have the ActivityIndicator equal to true. What I’m doing wrong?

This is my code. 

protected static void SendEmail(string message, PXGraph Base, CustomDAC transaction)
{
Notification notification = PXSelect<Notification,
Where<Notification.name, Equal<Required<Notification.name>>>>
.Select(Base, new object ] { "my template" });

bool sent = false;
string sError = "Failed to send E-mail.";
try
{
TemplateNotificationGenerator sender = TemplateNotificationGenerator.Create(transaction, notification.NotificationID.Value);
sender.MailAccountId = (notification.NFrom.HasValue)
? notification.NFrom.Value
: PX.Data.EP.MailAccountManager.DefaultMailAccountID;
sender.RefNoteID = transaction.Noteid;
//sender.Owner = notification.NFrom;
sender.To = notification.NTo;
sender.Body = notification.Body.Replace("((#replace#))", message);
var activitieds = sender.Send();
}
catch (Exception ex)
{
sent = false;
sError = ex.Message;
}
}

Thanks,

EV


Hi,

Maybe you don’t have Email Accounts in Acumatica, and email notification does not start its logic. 

Check System Email Accounts and Email Preferences screen, setup some testing default email account, and try again.

Your email notification you could check on processing screen SM507000 (Emails Pending Processing), but don’t click Process All, it will send all email to users😀

Method sender.Send() only adds notification to processing screen.

And last point, it is my method that sends emails and it works.

 

   public virtual void SendEmailNotification(string email, string emailBody)
        {
            var sender = new NotificationGenerator
            {
                To = email,
                Subject = string.Format(Messages.subjectString, this.Base.AppointmentRecords.Current.RefNbr, this.Base.AppointmentRecords.Current.ScheduledDateTimeBegin.ToString()),
                Body = emailBody,
                BodyFormat = EmailFormatListAttribute.Html
            };
            sender.Send();
        }



Reply