Reading SMTPServer

I am sending SMTP Email. I am instanciating a SMTPClient with hard coded SMTP Server and port. Like this SmtpClient client = new SmtpClient(“SMTPServer”, 25); I would like to read it out of Company Maintenance and use it that way instead of hard coding it. I think I would need to use CompanyImpl but after that, I’m not sure. Can this be done? If so, do you guys have any examples I can look at?

Is this a BPM or are you trying to do it client-side?

Here is some boiler plate that I use for sending emails from BPMs:

var mailer = this.GetMailer(async: true);
var message = new Ice.Mail.SmtpMail();
message.SetFrom("");
message.SetReplyTo("");
message.SetTo("");
message.SetSubject("");
message.SetBody("");
message.IsBodyHtml = true;
mailer.Send(message);

I haven’t thought about it until now, but I’m guessing the Ice.Mail.SmtpMail() method is already reading the smtp information from the Company table… At least, I’m not sure how it works if it’s not doing that…

I am trying to do it in the Quote customization.

In that case you could use a BAQ (DynamicQueryAdapter) or the Company adapter to read in the data.

Cool. I didn’t think of that.

Epicor has a built in Email handler on the customization you can use

EmailArgs args = new EmailArgs();
args.ToAddress = "test@epiusers.com";
args.Subject = "Please format your code for the love of God!";
args.MessageBody = "Simply put ``` before and after your code it will make EVERYONE happier";
args.FromAddress = "EVERYONE@e10help.com";
EmailHandler.SendMail(args);

It reads the SMTP information from your SysConfig File

4 Likes

Good to know. Thanks Jose!

Thanks Jose. I didn’t know that.