Send Email from Customization

For some reason you dont have your epicor mailer set up, you can do the old fashioned way:

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;
smtpClient.EnableSsl = true;
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