[Solved] Unable to send E-mail with Attachment


According to http://msdn.microsoft.com/en-us/library/6sdktyws.aspx your Attachment constructor is trying to set the ContentType with the second parameter but you’re passing in a filename, are you sure that is correct?

You should probably change that part to something like:

ContentType contentType = // create suitable type here based on your file format
Attachment attachment = new Attachment(
    FileUpload.PostedFile.InputStream,
    contentType
);
attachment.ContentDisposition.FileName = FileUpload.FileName;
message.Attachments.Add(attachment);

solved Unable to send E-mail with Attachment