cancel
Showing results for 
Search instead for 
Did you mean: 

Convert file to Binary and get MIME type

john.hammond
Level 6
Afternoon all. I'm experimenting with using the 'Send Mail' functionality from the Outlook Graph API connector, but the required collection for Attachments requires 3 columns - the name of the file, the MIME type of the file (e.g. application/pdf) and the content of the file in binary. Previously, using the Outlook VBO, you simply needed a filepath to the file to be attached. Are there any objects that could reliably and consistently provide the MIME type for a given file and convert it into binary data for use with this action?

------------------------------
John Hammond
------------------------------
1 BEST ANSWER

Helpful Answers

john.hammond
Level 6
Apologies - spent a bit more time playing with this and 'kinda' figured it out, in case anyone else finds themselves in need (although any better ways of getting the MIME type would probably not be a bad idea):

Didn't realise but one of the File functions (LoadBinaryFile) in a calc stage has the ability to convert a file into binary data, so that was the first problem solved. As for the MIME type, I made up a collection of the common file extensions we may end up emailing (came up with about 18 at the moment) and then looped through this collection, comparing it against the extension of the file I was trying to attach. Works a charm now!

------------------------------
John Hammond
------------------------------

View answer in original post

2 REPLIES 2

john.hammond
Level 6
Apologies - spent a bit more time playing with this and 'kinda' figured it out, in case anyone else finds themselves in need (although any better ways of getting the MIME type would probably not be a bad idea):

Didn't realise but one of the File functions (LoadBinaryFile) in a calc stage has the ability to convert a file into binary data, so that was the first problem solved. As for the MIME type, I made up a collection of the common file extensions we may end up emailing (came up with about 18 at the moment) and then looped through this collection, comparing it against the extension of the file I was trying to attach. Works a charm now!

------------------------------
John Hammond
------------------------------

Hi @john.hammond,

FWIW - There is a method in the .NET Framework that will return the MIME mapping for a specified file. You can find more about it here.

Cheers,


------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------