I have the below details as string i want to fetch each data separately like subject, date,... Is it possible.
Subject: Re: mr
Thread-Topic: mr
Thread-Index: AQHZNeFl9xUBUVmA0kuT2sZAbo1Dyq65WjRY
Date: Wed, 1 Feb 2023 02:15:09 +0000
Message-ID:
References:
In-Reply-To:
Naimish MakwanaPosted Feb 1, 2023, 5:47 AM
Hello Gopi,
Use below code.
Thanks
Pasang TamangPosted Feb 1, 2023, 6:46 AM
Hi,
Either you have to generate Regex that match with your output or you can follow the way I suggested in previous response. To get message id only, you can add if condition to match the title. Below is the code example.
Regards,
Pasang
GopiPosted Feb 1, 2023, 6:05 AM
It working fine if it has only one value.
If has mutliple values it pull out only the first value.
Values like below
how to fetch all value
Muhammad Imran AnsariPosted Feb 1, 2023, 5:20 AM
Hi Gopi - you can extract the Message-ID from the string use the 'Regex' class and its 'Match' method to match the input string against the pattern. Regex class is available in System.Text.RegularExpressions namespace. Here is the code:
Pasang TamangPosted Feb 1, 2023, 4:48 AM
Hi,
Looking into your content, you get multiline string. To read value of each title you have to split based on new line. And then after to separate title and value split based on :. Please refer to below code example.
In above code you see that value is not retrieve by doing str[1]. That is because your value like Subject: Re: mr will have problem. So, I use str[0] to read title and then used substring to get value.
I hope this will be helpful to you.
Regards,
Pasang