While working on email functionality I also had same issue.
It's because we are directly using file name from upload.
To solve issue I saved the file from uploaded to temporary upload folder on server.
Then send the mail with attachment.
After that clear uploaded file from temporary upload folder.
Please check out below code.
string attach1 = string.Empty;
string strFileName = string.Empty;
MailMessage message = new MailMessage();
if (attachFile1.PostedFile != null && attachFile1.PostedFile.FileName != string.Empty)
{
HttpPostedFile ulFile = attachFile1.PostedFile;
Int64 nFileLen = ulFile.ContentLength;
if (nFileLen > 0)
{
strFileName = Path.GetFileName(attachFile1.PostedFile.FileName);
strFileName = WebConfigurationManager.AppSettings["Uploads"] + "/" + strFileName;
attachFile1.PostedFile.SaveAs(Server.MapPath(strFileName));
MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
message.Attachments.Add(attach);
attach1 = strFileName;
}
}
message.From = txtFrom.Text;
message.To = txtTo.Text;
message.Cc = txtcc.Text;
message.Bcc = txtbcc.Text;
message.Subject = txtSubject.Text;
message.Body = hdnmsg.Value;
message.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = WebConfigurationManager.AppSettings["Host"];
SmtpMail.Send(message);
if (attach1 != string.Empty)
File.Delete(Server.MapPath(attach1));