Automatic email documents generated out of Epicor

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