0

I want to get the extension of the file in the attatchement not sure how to do this, below is my code, in the mailMessage.Add im adding input stream, file name how do i add extension? below is my code

if (unauthenticatedEnquiryViewModel.File != null) // this finds overall null
{
    foreach (var file in unauthenticatedEnquiryViewModel.File) // loop through every File
    {
        if (file != null) //Finds induvidual null
        {
            mailMessage.Attachments.Add(new Attachment(file.InputStream, file.FileName, file.);

            mailMessage.Body = mailbuilder.ToString();
         }
     }
 }
Tieson T.
  • 20,774
  • 6
  • 77
  • 92

1 Answers1

0
var extension = new FileInfo(file.FileName).Extension.ToUpper();

then pass that in

mailMessage.Attachments.Add(new Attachment(file.InputStream, file.FileName, extension));
mason
  • 31,774
  • 10
  • 77
  • 121