Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Models.Helpdesk.Email obj = new Models.Helpdesk.Email();
- obj.MessageNumber = i;
- obj.MessageId = message.Headers.MessageId;
- obj.From = message.Headers.From.Address;
- obj.Subject = message.Headers.Subject;
- obj.Reference = message.Headers.References;
- OpenPop.Mime.MessagePart plaintxt = message.FindFirstPlainTextVersion();
- if ((plaintxt != null))
- {
- obj.Body = plaintxt.GetBodyAsText();
- }
- else
- {
- if ((htmltxt != null))
- {
- obj.Body = htmltxt.GetBodyAsText();
- }
- else
- {
- obj.Body = "";
- }
- }
- obj.DateSent = message.Headers.DateSent;
- obj.Recvd = message.Headers.Date;
- Just chillin, you?
- Yours sincerely
- *Testperson*
- Developer
- *Companyname *
- *emailA@gmail.com
- <http://goog_1337018965/> Facebook <http://www.facebook.com>
- <http://goog_1337018972/> Twitter <https://twitter.com/#!>
- D 28. januar 2015 kl. 09.16 wrote Test Test <emailA@gmail.com>:
- > What are you doing Dan
- >
- > D 28. januar 2015 kl. 09.12 wrote Test Test <emailA@gmail.com>:
- >
- > Hey Steve
- >>
- >> D 28. januar 2015 kl. 09.09 wrote Test Test <emailA@gmail.com>:
- >>
- >> Hey Dan
- >>>
- >>> Yours sincerely
- >>>
- >>>
- >>>
- >>> *Testperson*
- >>>
- >>> Developer
- >>>
- >>> *Companyname *
- >>>
- >>>
- >>> <http://goog_1337018965/> Facebook <http://www.facebook.com>
- >>> <http://goog_1337018972/> Twitter
- >>> <https://twitter.com/#!>
- >>>
- >>>
- >>
- >
- static string GetLastResponse(string message, string delimeter = "From:")
- {
- int delimeterPosition = message.IndexOf(delimeter);
- return (delimeterPosition > -1)
- ? message.Substring(0, delimeterPosition)
- : message;
- }
- obj.Body =
- @"Thanks, can't wait to see you!
- Thanks,
- Dan
- From: Jack Smith
- Sent: Tuesday, January 27, 2015 1:15 PM
- To: Dan Smith; Ron Smith; Betty Smith
- Cc: Jane Doe; John Doe
- Subject: RE: Family Reunion
- + Dan
- Dan, if you can go, I can go!
- Thanks,
- Jack
- From: Ron Smith
- Sent: Tuesday, January 27, 2015 1:15 PM
- To: Jack Smith; Betty Smith
- Cc: Jane Doe; John Doe
- Subject: RE: Family Reunion
- What do you guys think about getting together for drinks on Saturday?
- Thanks,
- Ron";
- string lastResponse = GetLastResponse(obj.Body);
- Console.WriteLine(lastResponse);
- private static string GetLastResponse(string message, string delimStartsWith,
- string delimContains, string delimEndsWith,
- StringComparison comparison = StringComparison.Ordinal)
- {
- if (string.IsNullOrWhiteSpace(message)) return message;
- var lastResponse = new StringBuilder();
- var lines = message.Split(new[] {"rn", "n"}, StringSplitOptions.None);
- foreach (var line in lines)
- {
- // Check to see if this line starts with, contains,
- // and ends with the specified text
- if ((delimStartsWith == null || line.StartsWith(delimStartsWith, comparison)) &&
- (delimContains == null || line.IndexOf(delimContains, comparison) >= 0) &&
- (delimEndsWith == null ||line.EndsWith(delimEndsWith, comparison)))
- {
- // If we get here it means all our conditions were met, so this
- // line is a delimeter and we should break out of this loop.
- break;
- }
- // Haven't reached a delimeter yet, so add this line to our lastResponse
- lastResponse.AppendLine(line);
- }
- return lastResponse.ToString();
- }
- string lastResponse = GetLastResponse(conversation, "D ", " wrote ", ".com>:");
- Console.WriteLine(lastResponse);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement