I am trying to send an email with an attachment that will be uploaded by the user and then sent to an admin email.
I have got this configured correctly on IE 11 but however with Chrome/Firefox there is limitations with the FilePath it provides. As IE 11 provides the full file path it allows my function to work.
Is there a possible way round this for Chrome/Firefox.
Mail Message code:
protected void Submit_Click(object sender, EventArgs e)
{
using (MailMessage message = new MailMessage())
{
if (Attachment1.HasFile == false)
{
message.From = new MailAddress(Environment.UserName + "@domain");
message.To.Add(new MailAddress("MyEmail"));
message.IsBodyHtml = true;
message.Subject = "New Request from self service portal: " + Summary.Text.ToString();
message.Body = "Customer Name:</br>Customer Username:" + Environment.UserName + "</br>" + DetailedSummary.Text.ToString();
SmtpClient client = new SmtpClient();
client.Host = "IP ADDRESS";
client.Send(message);
} else {
message.From = new MailAddress(Environment.UserName + "@domain");
message.To.Add(new MailAddress("myemail"));
string file = Attachment1.PostedFile.FileName;
message.Attachments.Add(new Attachment(file));
message.IsBodyHtml = true;
message.Subject = "New Request from self service portal: " + Summary.Text.ToString();
message.Body = "Customer Name:</br>Customer Username:" + Environment.UserName + "</br>" + DetailedSummary.Text.ToString();
SmtpClient client = new SmtpClient();
client.Host = "IP ADDRESS";
client.Send(message);
}
}
}
This is where the user will specify which file will be uploaded and will not be a static file being uploaded every time. Meaning, i will need the filepath from the FileUpload.