Built in email handler

Does anyone have documentation regarding the EmailArgs object? I know there are the basic properties such as ToAddress, Subject, MessageBody and FromAddress. I plan on using a colon separated string for multiple email addresses. However, I was curious what other properties I can set and if there are any other methods that might be better to use to add multiple email addresses.

Hi Melanie,
Welcome!

I chose to create a custom Epicor Function for sending our notification emails, with the following parameters:

  • AddressFrom
  • AddressTo
  • AddressCC
  • AddressBCC
  • AddressReplyTo
  • Subject
  • Body

The function uses a Custom Code block, with the following code:

var notificationSettings = Db.UD10.FirstOrDefault(row => row.Company == callContextClient.CurrentCompany && row.Key1 == "NOTIFICATION" && row.Key2 == "GLOBAL");

if (string.IsNullOrWhiteSpace(AddressFrom))
{
  AddressFrom = notificationSettings.Character05;
}

var subjectPrefix = notificationSettings.Character08;
if (!string.IsNullOrWhiteSpace(subjectPrefix))
{
  Subject = subjectPrefix + " " + Subject;
}

var bodyPrefix = notificationSettings.Character09;
if (!string.IsNullOrWhiteSpace(bodyPrefix))
{
  Body = bodyPrefix + "<br><br>" + Body;
}

var mailer = this.GetMailer(async:true);
var message = new Ice.Mail.SmtpMail();

message.SetFrom(AddressFrom);
message.SetTo(AddressTo);
message.SetCC(AddressCC);
message.SetBcc(AddressBCC);
message.SetReplyTo(AddressReplyTo);
message.SetSubject(Subject);
message.SetBody(Body);

message.IsBodyHtml = true;
mailer.Send(message);

We use User Defined table 10 (UD10) to store custom settings. In this case we use it to define some ‘Prefix’ text that we prepend, such as ‘TEST’ for example, to indicate that the email came from our Test environment.

We can call this Function from BPMs, etc, or via the REST API.

I just may have to do something similar. I like this idea. Thank you!

Same here! That, and I added 4 extra large string columns to UDCodes.

:slight_smile:

1 Like

I don’t suppose you would know why I am getting these errors? Brand new library, brand new function, installed .Net 6 SDK…

Maybe some help in this thread? Seems like some people were able to fix it, others not… no true solution marked in the thread.

Yeah. I saw that thread. I have done all of those steps. I guess I’m just in the group that is S.O.L. Thank you for your response though!