Error while using replace function

Hi All,

Error When I tried to execute the below expression in assign activity to replace

ForwardTitle.Replace(“(?SentDate)”,DateTime.ParseExact(item.Headers(“DateCreated”), “MM/dd/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dddd, MMMM dd, yyyy h:mm tt”))

Error :

Replace Sent Date: String reference not set to an instance of a String.
Parameter name: s

Can anyone help me to solve this issue?

Hi @rnahasnahasuddin
Could you try this

ForwardTitle.Replace(“(?SentDate)”,DateTime.ParseExact(item.Headers(“DateCreated”).ToString.Trim, “MM/dd/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dddd, MMMM dd, yyyy h:mm tt”))

Thanks,
Nived N

Hi @NIVED_NAMBIAR

I have tried this, but got this error Replace Sent Date: Object reference not set to an instance of an object.

Make sure this part is returning a value. Certain versions of UiPath.Mail.Activities had bugs where the headers weren’t returned properly.

Could you check any value is null here , like forwarddate or item.Headers(“DateCreated”) ?

I have checked the output of item.Headers(“DateCreated”), it is a null value.

Currently I’m using office 365 activities to read the mails and it doesn’t have a key like DateCreated.

So, can you help to find the replacement of DateCreated key in office 365 get mail activity.

Update your dependency to the latest version and try again.

But still getting null values for item.Headers(“SentDateTime”) and for item.Headers(“ReceivedDateTime”)

I’m using the latest version of office 365 package

That’s because those headers don’t exist. Try item.Headers(“Date”)