How to insert string data into datatable

I have one string data

Date/Time sent: 02/01/2020 17:18:15
Subject line: My Own Data 
From: noreply@ak.com
To: lokeshk@ak.com
Action taken: Deleted Message
Rule Group: AA_BA_URL, DD_D0_PN, ME_BD_MA_HE, PHP_QD, R
Size: 34331
File: 
Server: ARE
Task: Access (Time)
Ticket Number: 1111-11-11-0001
Sender IP: 00.00.00.00

I want to insert this key value data in datatable seprated by (:). but some extra colons are there in value ex: (“Date/Time sent”: “02/01/2020 17:18:15”) So how can i insert data in datatable as 2 rows one for key and second for value.

1 Like

First split the string in to new lines
YourString.Split(Environment.NewLine.ToArray,StringSplitOptions.RemoveEmptyEntries)

Then loop it and again split it by
YourString.Split(": “c)(0)
YourString.Split(”: "c)(1)

Add above value in DT as key and Value

1 Like

@karthick

Can you provide me sample code to add key, value in datatable 2 rows.