Skip to main content

Hi,

I’ve created a Task in NWC to send an email with multiple attachment files via Microsoft Graph API SendMail. This uses a jason string to construct the message.

 

I have a the string below representing one file to be sent with the email.

​{
     "@odata.type": "#microsoft.graph.fileAttachment",
     "name": "​‍file.pdf‍​",
     "contentType": "text/plain",
     "contentBytes": "​h5+9v8pGhhIHNOKBHU3jLVRWUtpw355h"
}​

 

I need a way to append additional files in this exact format .

 

How do I append to a string in NWC to form one String?

Please note that I’m using the “Create a text string” task.


Hello @Mdu,

Is this what you asking?

In my image below, I am appending Variable1 with Variable 2 and Variable3, saving the end result back into Variable1. This pattern is ideal inside loops.
 

Please let me know if I am not understanding the issue correctly


Hi @AnthonyD,

 

The challenge is that the I don’t have a fixed number of files(variables), the number variables will change based on a scenario.

I’m basically looking to do something like this.

 

string finalName = string.Empty;
foreach(row in Dataset)
{
finalName += row.name;
}

 

 


Hello @Mdu ,

Do you have a count or a collection of items that you can use to perform the loop?

If you so you can do the following?

 

in the create a text string ….
(Variable 1 would be the text/json you want to build up)
(Variable 2 would be the new file json to add)

 

Does this help?


Yes I do have a collection, but his would work if I know the exact number of string variables to create.

In my case the the string variables could be 1 or many depending on the number of files, therefore I wouldn't know the number of variables to create upfront.

 

It has to be dynamic.


@AnthonyD I think you are on to something, let me try your suggestion first I’ll let you know if it works or not.


Hi @AnthonyD ,

 

I tried your suggestion, It only works with two files, when I add the third file the workflow throws the error “The workflow has failed unexpectedly. lError Code: Runtime.Internal]”

I suspect that the string gets too long to store in the output variable as the string is a a base64 string which is very long.

Is there a way to know exactly what the cause of the error is? 


Hi @AnthonyD,

 

I moved the functionality to another workflow and the error is gone.

Your solution worked for me, thanks a lot for your assistance. 


Reply