I have to check rows of Quantity, Weight, Total Money of dt1 & dt2
Currently compare row by row of Q,W,T dt1vsdt2 if not equal will stop and send an email. I use try catch and exception email.
But I want: to check all to the last row and consolidate messages to be sent at the end (stop at the end)
Hey @anh.nguyen ,
Can you give a try of below sequence
Initialize Variables:
consolidatedMessage (String) = “”
For Each Row (row in dt1):
If row(“Quantity”) <> dt2.Rows(rowIndex)(“Quantity”) Or
row(“Weight”) <> dt2.Rows(rowIndex)(“Weight”) Or
row(“Total Money”) <> dt2.Rows(rowIndex)(“Total Money”):
Add to consolidatedMessage:
- Append line with discrepancy information to consolidatedMessage
After Loop (outside For Each Row):
If consolidatedMessage is not empty:
Send Email:
- Recipient: Your Email
- Subject: “Consolidated Discrepancies Report”
- Body: consolidatedMessage