本文介绍了子串,修剪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好.
我正在尝试使用C#检索电子邮件.我得到了我所需要的一切.但是问题在于消息内容即将来临..
Hi every one.
I am trying to retrieve email by using C#. I got every thing I required. But the problem is the message content is coming like..
--0016367fb7376bfdc30499a12567
Content-Type: text/plain; charset=ISO-8859-1
Your Text message.
--0016367fb7376bfdc30499a12567
Content-Type: text/html; charset=ISO-8859-1
我只需要内容
I need to take only the content
Your Text message.
任何人都可以通过给出逻辑来帮助我,我该如何找回它.
条件是
Can any one please help me out by giving the logic, how can I retrieve it.
The condition is
--0016367fb7376bfdc30499a12567
Content-Type: text/plain; charset=ISO-8859-1
对于不同的邮件可以有所不同,但相同的顺序将是特定顺序的两倍.
在此先感谢.
can be different for different mails but the same will be twice in that particular order.
Thanks in advance.
推荐答案
--0016367fb7376bfdc30499a12567Content-Type: text/plain; charset=ISO-8859-1
A0AKKmasaieTTYYIOIOIMddssPP...--++yyyYYYYYour Text messageA0AKKmasaieTTYYIOIOIMddssPP...--++yyyYYYY
.--0016367fb7376bfdc30499a12567Content-Type: text/html; charset=ISO-8859-1
现在您已经有了字符串的起点和终点,可以很轻松地删除废物.
Now you have start and end point of your string and it will be simple to delete wastes.
private string FixString(string message)
{
string[] fixedCode =new string[1] {"A0AKKmasaieTTYYIOIOIMddssPP...--++yyyYYYY"};
StringSplitOptions option = StringSplitOptions.None;
string[] messages = message.Split(fixedCode, option);
for (int i = 0; i < messages.Length;i++ )
{
if (i == 1)
return messages[i];
}
return string.Empty;
}
现在,您可以找到您的主要信息:
Now, you can find your main message:
string k = @"--0016367fb7376bfdc30499a12567Content-Type: text/plain; charset=ISO-8859-1
Your Text message.A0AKKmasaieTTYYIOIOIMddssPP...--++yyyYYYYHelloA0AKKmasaieTTYYIOIOIMddssPP...--++yyyYYYY--0016367fb7376bfdc30499a12567Content-Type: text/plain; charset=ISO-8859-1
Your Text message.";
Console.WriteLine(FixString(k));
这篇关于子串,修剪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!