Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. Models.Helpdesk.Email obj = new Models.Helpdesk.Email();
  2.  
  3. obj.MessageNumber = i;
  4. obj.MessageId = message.Headers.MessageId;
  5. obj.From = message.Headers.From.Address;
  6. obj.Subject = message.Headers.Subject;
  7. obj.Reference = message.Headers.References;
  8.  
  9. OpenPop.Mime.MessagePart plaintxt = message.FindFirstPlainTextVersion();
  10.  
  11. if ((plaintxt != null))
  12. {
  13. obj.Body = plaintxt.GetBodyAsText();
  14. }
  15. else
  16. {
  17. if ((htmltxt != null))
  18. {
  19. obj.Body = htmltxt.GetBodyAsText();
  20. }
  21. else
  22. {
  23. obj.Body = "";
  24. }
  25. }
  26.  
  27. obj.DateSent = message.Headers.DateSent;
  28. obj.Recvd = message.Headers.Date;
  29.  
  30. Just chillin, you?
  31.  
  32. Yours sincerely
  33.  
  34. *Testperson*
  35.  
  36. Developer
  37.  
  38. *Companyname *
  39.  
  40. *emailA@gmail.com
  41.  
  42.  
  43. <http://goog_1337018965/> Facebook <http://www.facebook.com>
  44. <http://goog_1337018972/> Twitter <https://twitter.com/#!>
  45.  
  46.  
  47. D 28. januar 2015 kl. 09.16 wrote Test Test <emailA@gmail.com>:
  48.  
  49. > What are you doing Dan
  50. >
  51. > D 28. januar 2015 kl. 09.12 wrote Test Test <emailA@gmail.com>:
  52. >
  53. > Hey Steve
  54. >>
  55. >> D 28. januar 2015 kl. 09.09 wrote Test Test <emailA@gmail.com>:
  56. >>
  57. >> Hey Dan
  58. >>>
  59. >>> Yours sincerely
  60. >>>
  61. >>>
  62. >>>
  63. >>> *Testperson*
  64. >>>
  65. >>> Developer
  66. >>>
  67. >>> *Companyname *
  68. >>>
  69. >>>
  70. >>> <http://goog_1337018965/> Facebook <http://www.facebook.com>
  71. >>> <http://goog_1337018972/> Twitter
  72. >>> <https://twitter.com/#!>
  73. >>>
  74. >>>
  75. >>
  76. >
  77.  
  78. static string GetLastResponse(string message, string delimeter = "From:")
  79. {
  80. int delimeterPosition = message.IndexOf(delimeter);
  81.  
  82. return (delimeterPosition > -1)
  83. ? message.Substring(0, delimeterPosition)
  84. : message;
  85. }
  86.  
  87. obj.Body =
  88. @"Thanks, can't wait to see you!
  89.  
  90. Thanks,
  91. Dan
  92.  
  93. From: Jack Smith
  94. Sent: Tuesday, January 27, 2015 1:15 PM
  95. To: Dan Smith; Ron Smith; Betty Smith
  96. Cc: Jane Doe; John Doe
  97. Subject: RE: Family Reunion
  98.  
  99. + Dan
  100.  
  101. Dan, if you can go, I can go!
  102.  
  103. Thanks,
  104. Jack
  105.  
  106. From: Ron Smith
  107. Sent: Tuesday, January 27, 2015 1:15 PM
  108. To: Jack Smith; Betty Smith
  109. Cc: Jane Doe; John Doe
  110. Subject: RE: Family Reunion
  111.  
  112. What do you guys think about getting together for drinks on Saturday?
  113.  
  114. Thanks,
  115. Ron";
  116.  
  117. string lastResponse = GetLastResponse(obj.Body);
  118.  
  119. Console.WriteLine(lastResponse);
  120.  
  121. private static string GetLastResponse(string message, string delimStartsWith,
  122. string delimContains, string delimEndsWith,
  123. StringComparison comparison = StringComparison.Ordinal)
  124. {
  125. if (string.IsNullOrWhiteSpace(message)) return message;
  126.  
  127. var lastResponse = new StringBuilder();
  128. var lines = message.Split(new[] {"rn", "n"}, StringSplitOptions.None);
  129.  
  130. foreach (var line in lines)
  131. {
  132. // Check to see if this line starts with, contains,
  133. // and ends with the specified text
  134. if ((delimStartsWith == null || line.StartsWith(delimStartsWith, comparison)) &&
  135. (delimContains == null || line.IndexOf(delimContains, comparison) >= 0) &&
  136. (delimEndsWith == null ||line.EndsWith(delimEndsWith, comparison)))
  137. {
  138. // If we get here it means all our conditions were met, so this
  139. // line is a delimeter and we should break out of this loop.
  140. break;
  141. }
  142.  
  143. // Haven't reached a delimeter yet, so add this line to our lastResponse
  144. lastResponse.AppendLine(line);
  145. }
  146.  
  147. return lastResponse.ToString();
  148. }
  149.  
  150. string lastResponse = GetLastResponse(conversation, "D ", " wrote ", ".com>:");
  151.  
  152. Console.WriteLine(lastResponse);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement