Sending Emails: Input string was not in a correct format

Hi everyone! I´m new to UI Path. I´m trying to automate sending emails, so I have an excel sheet with 2 columns, name and email addresses.

I found Palaniyappan´s tutorial (Uipath academy - advanced - UiPath Community Forum)Send email with excel fields in body on how to do it but I´m stuck at the last part:

Is there something wrong with my ¨body_Text¨ type?

Many thanks in advance!

1 Like

@aphieme

Welcome to uipath community.

May I know what error are you getting here ?

Is outlook application installed in this machine ?

Hi @aphieme

With the Info Provided , only thing I can see is Out2 is declared as a genericvalue ,
can you try updating the datatype to String instead of generic.

–Mukesh

Hi @lakshman! Thanks, yes, I have downloaded the outlook application in the machine.

The error that I am getting is (The input string was not in a correct format): RemoteException wrapping System.FormatException: La cadena de entrada no tiene el formato correcto.
en System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider,
String format,
ParamsArray args)
en System.String.FormatHelper(IFormatProvider provider,
String format,
ParamsArray args)
en lambda_method(Closure ,
ActivityContext )
en Microsoft.VisualBasic.Activities.VisualBasicValue1.Execute(CodeActivityContext context) en System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
en System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance,
Activity1 expressionActivity) en System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment,
ActivityInstance activityInstance,
ActivityExecutor executor)
en System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment,
ActivityInstance targetActivityInstance,
ActivityExecutor executor,
Object argumentValueOverride,
Location resultLocation,
Boolean skipFastPath)
en System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument,
Int32 nextArgumentIndex,
ActivityExecutor executor,
IDictionary2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) en System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides,
Location resultLocation,
Int32 startIndex)
en System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor,
BookmarkManager bookmarkManager,
Location resultLocation)

1 Like

Hi @Mukeshkala, yes I had tried changing it to a string format but it doesn´t work. The strange this is when i key in String.Format(“Hi {0}”, Out2) it works well. I wonder if it’s anything to do with my body_Text? My body_Text is just an output string variable from Read Text (of a notepad file).

Cheers!

Uploading my documents here, really appreciate any help :wink:

image

Hi @aphieme

Could you try to first use the Assign activity to make your String.Format transformation and then pass the result to the Send Outlook Mail Message?

It might be due to the activity not being able to handle this transformation.

Hi @loginerror, thanks for the comment. I tried using:
Assign
body_Text1 = String.Format(body_Text, Out2)

Send Message
Body: body_Text1

But as I debug the workflow, I still get the same error at the point of the Assign (Input String is not in correct format).

Hi @Palaniyappan , I tried using your instructions for Send email with excel fields in body but I got stuck at the last part, where I kept getting an error that my input string was not in a correct format. Would you be able to share some advice please? Thanks!

Hi @aphieme;
I suggest you follow the advice of @loginerror try first to create an assign activity for the email body. In my case I’ve handled it this way and I haven’tt had problems

Thanks @Cesar_Cotom, yup I tried that, for assign I did: body_Text1 = String.Format(body_Text, Out2).

Where body_Text is the message and Out2 is the name variable from the excelsheet.

May I see what did you key in for your assign value? From the screenshot I see ¨string.Format(vHtm…)

@Cesar_Cotom, would u be able to share your workflow with me? I would like to compare what you have done (and that it worked) with mine. Also, I note that I´m using send Outlook Message and you chose send message by SMTP.

Hi @aphieme,

I changed the scope of Out2 and ran with necessary changes and got the email. Please try with that as well and let me know.

Cheers

Thanks @kkasegaonkar, I changed the scope of Out2 to ¨body¨ and later to ¨test3¨ but it still doesn´t work. The error I get is: RemoteException wrapping System.FormatException: Input string was not in a correct format.

Here´s a screenshot:

Could you maybe share with us the source text file that you read into the variable before the assign? It seems that the formatting in that file might be causing the issue.

I would still try of it will work with a simple text file instead of the fully formatted email. Please try with a text file that contains only something like this:
testing {0}

Hi @loginerror, you know what, you are right. When I uploaded a simple text file with Test {0}, it worked perfectly. The error happens when my text file is a html code.

Is there anyway to run this programme with a text with HTML?

Here´s the content of my text file:

image

Could you maybe paste it as text? :smiley:

I tried some simple HTML and it worked, so it is a matter of finding the character that breaks in your sample (and I don’t feel like retyping it all :smiley: )

Nevermind, it is happening because of the curly braces { and }

Simply use two brackets to escape them, like so:

 .tab {{ margin-left:40px; }}

It will work then. I got the idea from here.

2 Likes

Thank you @loginerror! You are absolutely right! And further, I realised that I had to: 1) Add the “{” as you mentioned and 2) remove the redundant HTML (highlighted):

The only thing is that I still do not see the indent formatting on Gmail (but I do on outlook), but that´s all right. Thank you so much!!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.