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.
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);
}
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);
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.
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.
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.
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.
does @"\ERP10-APP\EpicorData\Companies\iei\BankVendorFile\Live\LiveVendor.txt" work?
looking at my server share it is the “EpicorData” folder instead of “Epicor”