I've tested this with my own email addresses and received the message and attachment.
Put this in the Careers class:
protected static readonly MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
protected static readonly List<MailAddress> to = new List<MailAddress> { new MailAddress("
[email protected]"), new MailAddress("
[email protected]"), new MailAddress("
[email protected]") };
Your new try block:
try
{
//'(1) Create the MailMessage instance
MailMessage mm = new MailMessage { From = from };
foreach (var recipient in to)
{
mm.To.Add(recipient);
}
//'(2) Assign the MailMessage's properties
mm.Subject = "Message Careers";
mm.Body = Body.Text;
mm.IsBodyHtml = false;
//'Attach the file
mm.Attachments.Add(new Attachment(AttachmentFile.PostedFile.InputStream, AttachmentFile.FileName));
// Copied from Nop:
var smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = MessageManager.AdminEmailUseDefaultCredentials;
smtpClient.Host = MessageManager.AdminEmailHost;
smtpClient.Port = MessageManager.AdminEmailPort;
smtpClient.EnableSsl = MessageManager.AdminEmailEnableSsl;
if (MessageManager.AdminEmailUseDefaultCredentials)
smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
else
smtpClient.Credentials = new NetworkCredential(MessageManager.AdminEmailUser, MessageManager.AdminEmailPassword);
smtpClient.Send(mm);
//'Show the EmailSentForm Panel and hide the EmailForm Panel
LBLSuccErr.Visible = true;
LBLSuccErr.ForeColor = System.Drawing.Color.Green;
LBLSuccErr.Text = "Your file has been submitted successfully";
}