Error while saving the outlook subject & date to an excel


#1

Hi All,

I am going through UI Path tutorial (11th Chapter i.e., Email Automation). i got “From, Subject, Date” in a variable & i got the data(reflects in message box). After adding those 3 variable in Input ArrowRow of “Add Data row” activity & running the workflow i am facing the below mentioned exception.

Source: Add data row
Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).
Exception Type: NullReferenceException

Please share some light on the above scenario OR if you have similar workflow can you share it

Regards,
Suhas


#2

@Suhas92
I think you created a datatable variable, but you might have missed to read an excel sheet and assign the value to DataTable Variable. Please Check once again the workflow. if every thing is fine then we can see other chances.

Regards,
Mahesh


#3

Hey, @Suhas92.

Try initializing the datatable in the variable panel.

Eg: DataTable dtMailInfo = new DataTable();


#4

Hey @siddharth & @MAHESH1

I tried both the things but did not work, Hence i have attached my workflow can you please take a look into these & let me know what is wrong in it

Thanks in advance

Main.xaml (13.9 KB)


#5

Suhas, I believe you’ve attached the wrong file. Please check it once and let me know when you attach the correct one.


#6

Oops, Sorry here is the correct one!!

Main.xaml (11.1 KB)


#7

@Suhas92

I saw your xaml. You are adding datarow to a DataTable. But you have not created a datatable either by using Build DataTable Activity or by reading an Excel sheet Template.

So First Build the DaTaTable then Add the DataRow.

After that Write the Excel Sheet by using WriteRange.

Regards,
Mahesh


#8

@MAHESH1,

I tried doing that as well but did again got the same error.

Check the attached “xaml” & It would be great if u can correct it??

many thanks

Main.xaml (15.4 KB)


#9

@Suhas92

Some corrections

  1. Use Build DataTable outside ForEach
  2. Change the DataType from Generic value to String
    3.Remove the Default row with some value in Build DataTable.

After these many changes Try by running once again.

Even After if you are getting error means, This might be the case, Suppose if you have not received any mail with respect to the given Filter, then the list of mail messages will be empty. And you have not initialized the DataTable. So it might be reason to through the exception.

Regards,
Mahesh


#10

Main (12).xaml (16.2 KB)

Here. I have made the changes…also I have unchecked the OnlyUnreadMessage property…
Because it might be the case that you don’t have any unread messages…so try this workflow and tell me if this works for you :slight_smile:


#11

Thanks @MAHESH1,

moving the Build data table activity outside FroEach did give me the desired output :slightly_smiling_face:


#12

Thanks @Niket_Ghai,

I used the workflow which you gave & it works perfectly. thanks a lot:ok_hand:
:blush: