MIMEType for email attachment

I am sending an attachment to an email (mostly PDFs, but possibly jpegs and other image formats), and I found I need to set the MIMEType for it to show up properly in the email.

For my initial testing, I was setting it to ‘application.pdf’, and this worked, but is there a way to determine in the code what the proper MIMEType is for the given folder item?

it’s application/pdf.

you find those when you add a file type set and add file types via menu.

Sorry, I probably didn’t express my question properly. I will have different file types, not just PDFs, that I need to determine the MIMEType on-the-fly. With a given file (i.e. JPEGs, or PNGs), is there a way to determine what the proper setting will be in code for that specific file?

I’ve been searching to see if I can determine the FileType associated with the given file, assuming I could get then get what I need from that (I believe the FileType .Name property would be what I need), but I don’t see how to get the FileType from a given FolderItem.

Xojo doesn’t determine the file type that comes from you when you tell the program what types you will be handling. Here is a reasonably complete list though I wouldn’t include all of them http://www.freeformatter.com/mime-types-list.html . On Linux I would just use the file command to get the detected mime type of the file.

Thanks. The ‘File’ command seems to work on my Mac (which is the target OS for this application), so I believe a shell call should do what I need. Do you know if there are any issues I may run into with this method?

It has worked well for me the last four years. There are a few cases where the file command will get confused by the contents of the file but that just means that rarely you may get the wrong icon.

Here’s some code that initializes a Dictionary of mimetypes keyed to the file extension.