Automatic email documents generated out of Epicor

It looks like we will go down this road then…part of our upgrade…fun! M

1 Like

thanks, Miguel…at least something else to compare APM to…Manasa

If you have access to an SMTP email server, it is pretty straightforward to send email using custom C# code in BPM (I have never used built in EMAIL object). I can share code if you like.

You could always generate your report to a local PDF, then attach it in email.

Hhhmmm…Chris, I may take you up on that….would you be willing to talk of list to discuss more?

M. Manasa Reddy
P: 703.471.7145 x454
manasa@euclidsys.commailto:manasa@euclidsys.com

This is the code I used within a form customization - It should be the same except for in a BPM you can use MssageBox.Show, you have to use the ICE message box. I hope this helps! I would also like to note, you can use your GMAIL account for SMTP as well if you use the right settings. -Chris

SmtpClient smtpClient = new SmtpClient();
NetworkCredential basicCredential = 
    new NetworkCredential("uremail@domain.com", urpassword); 

MailAddress fromAddress = new MailAddress("WhoIsSender@domain.com"); 

smtpClient.Host = "mail.yourSMTP.com";
smtpClient.Port = 25;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = basicCredential;

MailMessage message = new MailMessage();
//-------> THIS IS WHAT YOU WANT!  ---->message.Attachments.Add(new Attachment(PathToAttachment));

message.From = fromAddress;
message.Subject = "Testing customiztion from E10";
//Set IsBodyHtml to true means you can send HTML email.
message.IsBodyHtml = true;

message.Body = "<h1>This was created from within EPICOR..</h1><BR>On the receipt entry screen";
message.To.Add("receipient1@domain.com");

try
{
    smtpClient.Send(message);
}
catch(Exception ex)
{
    //Error, could not send the message
 //   Response.Write(ex.Message);
MessageBox.Show(ex.Message);
}
2 Likes

Cool, thank you….we shall try it. :smiling_face:

M. Manasa Reddy
P: 703.471.7145 x454
manasa@euclidsys.commailto:manasa@euclidsys.com

1 Like

Sorry for the typo’s I meant to say you CANT use MessageBox.Show in a BPM. Also, dont forget to add these directives:

using System.Net;
using System.Net.Mail;

Pretty nice @Chris_Conn ,
For what its worth if you are in a BPM you can use the built in Epicor Mailer class to send SMTP email with attachments. This makes it a little simpler since it will use the configured Epicor SMTP settings that you’ve already established when you setup Epicor.

     var mailer = this.GetMailer(async: true);
     var message = new Ice.Mail.SmtpMail();
     message.SetFrom("email@email.com");
     message.SetTo("email1@email.com;email2@email.com");
     //message.SetCC()
     //message.SetBcc() 
     message.SetBody("<html><body><p>MyMessage Here</p></body></html>");
     Dictionary<string, string> attachments = new Dictionary<string, string>();
     attachments.Add("MyFirstAttachment", @"\\MyServer\myFolder\MyFile.pdf");
     mailer.Send(message, attachments);
8 Likes

Got it!

M. Manasa Reddy
P: 703.471.7145 x454
manasa@euclidsys.commailto:manasa@euclidsys.com

Nice, I have never used the email object - I have no control over the system configuration so I wasn’t sure if an SMTP was even configured. For future reference, is that simply configured in the SYSCONFIG? I think I saw some params for that.

The one that BPM uses is configured in Company Configuration

Mr. Gomez: Thank you so much for the code.

I ran a quick test and it works!

I must admit I was thinking this was going to be much more complicated - But it really is straight forward.

Thank you again,

DaveO

Jose,

thanks for this great information. I need assistance on this, this is the scenario:

I have a csv file in this location:
E:\Epicor\EpicorData\Companies\iei\BankVendorFile\Live\LiveVendor.txt
My server name is : ERP10-APP

I already tried
@"\Epicor\EpicorData\Companies\iei\BankVendorFile\Live\LiveVendor.txt"
@"\ERP10-APP\Epicor\EpicorData\Companies\iei\BankVendorFile\Live\LiveVendor.txt"
and does not work, no even email received.

but if I try :
@“E:\Epicor\EpicorData\Companies\iei\BankVendorFile\Live\LiveVendor.txt” , i works but i am getting an attachment that is not the one I want. it is like an video recorder installation program .dat

I am confuse because I do not where Epicor is attaching this program from.

thanks for any help on this
regards
Manuel

Are you doing this on a BPM? If so the file needs to be in the Epicor Server.

yes, I am doing this in a BPM and the file is stored in the app server.

well, now it is working and getting my correct attachment using this
@“E:\Epicor\EpicorData\Companies\iei\BankVendorFile\Live\LiveVendor.txt”

thanks a lot for your support

M

Hi is that possible to use C# custom to print to email instead of using the APM, I may want to try auto print the statement with criteria if matched with some addition note in my email, and attach the statement automatically.
My logic customization in Order Entry screen user able to send the statement to customer by just click the button, and all the works will be handle by C# coding internally.

Thanks.

Yes. Best to do it on the BPM side of things, but you can generate invoices, statements, etc then attach and email.

Hi jgiese, nice to hear that may I have some reference on this? of the sample code.

I could provide you my code however I’m not sure it would work for you and it’s a significant amount. I know that until 10.2.500 some of the stuff I’m using to achieve what you are doing is not available. My suggestion use traces on report printing to figure out what you need for code to reproduce that part of it, and if I had to guess sending BPM emails from code, even with attachments, is probably already in the forum somewhere.

Yes if possible please, just for my reference so that I can have an idea on how to route to other parameter.