Solved

Assistance with creating a draft with attachments in C#

  • 27 December 2022
  • 1 reply
  • 132 views

Badge +2

We are trying use the API to create a draft email with attachments, then a pop up for our users to modify the draft body and send the message.  We are trying to integrate this into our TMS and keep having issues with posting a multipart-form in C# that would get this to function correctly.

 

Can you please assist with an example or suggestions? 

 

We have reviewed the API guide as well as: https://gist.github.com/hdornier/e04d04921032e98271f46ff8a539a4cb, but have not been successful yet.  

icon

Best answer by Support Engineering 27 December 2022, 18:42

View original

1 reply

Userlevel 1
Badge +5

At the moment, we do not have specific C# examples to share or an SDK to leverage.

 

As a general guideline, you need to ensure that you send your payload with a Content-Type: multipart/form-data header, and send the binary file rather than encoding it as base64.

 

You can also find C# wrappers other people have used, but we cannot guarantee how well they will work for you. You can use them as a reference knowing they are not official in any way.

 https://github.com/cal5barton/frontsharp 

 

It does seem to implement multipart requests for sending messages: https://github.com/cal5barton/frontsharp/blob/1162814b99bc21974f6a8cc1d9c28cba849ee216/FrontSharp/FrontSharp/Requests/MessageRequests.cs#L62-L66 

 

 I see it hasn't been updated in a couple of years so it is possible that it might not be fully compatible with today's version of the API, but it should at least be a good starting point. For reference, I don't believe we have updated how attachments are expected to be provided for several years, so that part should work fine, provided the library works as expected!

 

--Jason

Reply