Server Side Programming for Email Generation

Epicor: 10.2.300.9

Requirement: To send a file from the Client computer as an attachment to the set of users through Email…

Action Taken:
Developed C# code to send an email on Client side as this is quite simple. This is achieved and is working (In Test Env. and for IT Peoples having full rights).

Problem:
However, for certain reasons, we need to move the functionality to Server Side. This is because, SMTP Ports are blocked on Client side OR restrictions on , hence Email is not delivering at all from the Client Form from Epicor Users.

Requirements:
1- Here, I need to write a simple C# file that should reside on the Server as a DLL, and functions could be available to be called from Cleint Forms. Can we do this using the available Epicor toolkit or using VS ?

2- Apart from this, is there any way (other than BPM) to call the existing Epicor functionality, where we could pass through the Email Object and Epicor Standard functionlaity could send it?

Awaiting the ideas !

Regards

So you can put your code in a UBPM which can have BPMs specific to it within in. Then you can call that BAQ client side using the dynamic query adapter and send your emails. It’s not the easiest thing to do, but once you get it set up it works pretty well.

Edit: I missed the file attachment requirement. I’m not sure how that would work.

1 Like

Try this type of code:

	//var mailer = this.GetMailer(async: true);
	var mailer = new Ice.Mail.SmtpMailer(this.Session);
	var message = new Ice.Mail.SmtpMail();
	message.SetFrom("me@epicor.com");
	message.SetTo("jack@epicor.com");
	message.SetCC("jill@epicor.com");
	message.SetBcc("ghost@epicor.com");
	message.Subject="Test Subject";
	message.Body = "Body Text";
	mailer.Send(message);
	
	//Add Attachments
	Dictionary<string, string> attachments = new Dictionary<string, string>();
	attachments.Add("AttachmentInfo", @"\\MyServer\MyFolder\MyFile.csv");
	mailer.Send(message, attachments);
1 Like

If you’re O365 users, you can use MSGraph, O365’s REST interface, to send mail from the client.

with attachments too:

1 Like

@Brandon
The important thing is the File attachment, if you have tried that , please share the code.
@Jason
The code you provided is same as I have, My point is to put this code on server side, please suggest.
@anon31358647
How may we use MS Graph in Epicor, specially at server where Office is not available?

The same way you can use Epicor on the client without having the software available by using REST over https. Did you go to the links? Check out the MS Graph Explorer if you have O365. Graph Explorer | Try Microsoft Graph APIs - Microsoft Graph

As @Brandon suggested, an updatable baq is a good starting point by using a pre-processing method. No need to update any data. Use the parameter to pass your input.

Or your could use UD01 (as example, what ever table you want) and call the GetList method. Use the where clause to pass your input as parameter.

For file attachment, is the file path sufficient? If so, just send it as string with your input.

The code that @Jason_Woods provided is server side. Just stick it in a BPM or UBAQ

You can call the UBAQ from the client side to excecute the UBAQ BPM as @Banderson said.

Thanks for all the support, I will try to move the Client Code to UBAQ and will check how does it work !
An update from myside is that I have changed the SMTP another server address internally, that is open for sending emails from Client, and its working fine with the clients. The only caveat is that since this process is synchronous (generating an SSRS Report, saving to local drive and attachign it to email), the user is not able to switch to other epicor windows until the process finishes.

Moreover, I must have the server side execution ready with me.

If, not sooner, I will be updating this Ticket as and when I do progress.