Why integrating SendGrid API with UiPath Mail Package, Email value is not accepting type String?

Hello @system ,

I have tried the 1st proposal solution, but seems that is not working as i get an error about the ‘Email’ value. It’s like it doesn’t accept the string value.

Can you help more?

I am hitting the same error. Were you able to resolve this?

unfortunately not @Shah_Hussain

Haven’t checked more since then, as we decided not to send emails at all in the end :stuck_out_tongue:

In case you find a solution for that, please let me know also here. I will do the same :wink:

Too late to reply, but i have figured out the solution to this and it shall help to anyone who is working with it.
Solution:

  1. The BodyFormData field in the Send Email activity of the sendgrid.integration.services will not accept the string input it only accepts the UI.Path.SendGrid.IntegrationServices.Client.Body format of the data.
  2. To make it work you have to convert your JSON request into a simplify it into a string friendly format and save it into a string type variable. After simplifying your json format should look like the below:
    Sample request:

"{ "from": { "email": "sender@example.com", "name": "John Doe" }, " +
""personalizations": [ { "to": [ { "email": "recipient1@example.com" }, " +
"{ "email": "recipient2@example.com" } ] } ], " +
""subject": "My Subject", " +
""content": [ { "type": "text/plain", "value": "This is the body of my email in plain text." }, " +
"{ "type": "text/html", "value": "This is the body of my email in HTML." } ], " +
“"attachments": [ { "filename": "my_attachment.pdf", "content": "BASE64_ENCODED_CONTENT", "type": "application/pdf" } ] }”;

  1. Now you just need to parse it through the Deserialize JSON activity and make sure the TypeArgument property of the Deserialize JSON should be set to “UI.Path.SendGrid.IntegrationServices.Client.Body”, (you can find this argument type in the browse for types if not available by default)
  2. Now store the output of this Deserialize JSON activity into a variable of type “UI.Path.SendGrid.IntegrationServices.Client.Body”.
  3. Now use this variable of “UI.Path.SendGrid.IntegrationServices.Client.Body” type in the BodyFormData of your sendgrid send email activity, it will work.
  4. Hit like if i helped😉

Please note: My project was of C# and not in the VB.NET

Source: Mail Send | Twilio

The source helped me to an extent.