@@ -86,6 +86,9 @@ public string[] ExtractToFolder(string inputFile, string outputFolder, bool hype
8686
8787 case "IPM.Task" :
8888 throw new Exception ( "An task file is not supported" ) ;
89+
90+ case "IPM.StickyNote" :
91+ return WriteStickyNote ( message , outputFolder , hyperlinks ) . ToArray ( ) ;
8992 }
9093 }
9194 }
@@ -293,11 +296,11 @@ private List<string> WriteEmail(Storage.Message message, string outputFolder, bo
293296 // End of table + empty line
294297 outlookEmailHeader += "</table><br/>" + Environment . NewLine ;
295298
296- body = InjectOutlookEmailHeader ( body , outlookEmailHeader ) ;
299+ body = InjectHeader ( body , outlookEmailHeader ) ;
297300 }
298301 else
299302 {
300- // Read all the language consts and get the longest
303+ // Read all the language consts and get the longest string
301304 var languageConsts = new List < string >
302305 {
303306 LanguageConsts . FromLabel ,
@@ -485,6 +488,68 @@ private List<string> WriteTask(Storage.Message message, string outputFolder, boo
485488 }
486489 #endregion
487490
491+ #region WriteStickyNote
492+ /// <summary>
493+ /// Writes the body of the MSG StickyNote to html or text and extracts all the attachments. The
494+ /// result is return as a List of strings
495+ /// </summary>
496+ /// <param name="message"><see cref="Storage.Message"/></param>
497+ /// <param name="outputFolder">The folder where we need to write the output</param>
498+ /// <param name="hyperlinks">When true then hyperlinks are generated for the To, CC, BCC and attachments</param>
499+ /// <returns></returns>
500+ private List < string > WriteStickyNote ( Storage . Message message , string outputFolder , bool hyperlinks )
501+ {
502+ var result = new List < string > ( ) ;
503+ string stickyNoteFile ;
504+ var stickyNoteHeader = string . Empty ;
505+
506+ // Sticky notes only have RTF or Text bodies
507+ var body = message . BodyRtf ;
508+
509+ // If the body is not null then we convert it to HTML
510+ if ( body != null )
511+ {
512+ var converter = new RtfToHtmlConverter ( ) ;
513+ body = converter . ConvertRtfToHtml ( body ) ;
514+ stickyNoteFile = outputFolder + "stickynote" + ".htm" ;
515+ stickyNoteHeader =
516+ "<table style=\" width:100%; font-family: Times New Roman; font-size: 12pt;\" >" + Environment . NewLine ;
517+
518+ if ( message . SentOn != null )
519+ stickyNoteHeader +=
520+ "<tr style=\" height: 18px; vertical-align: top; \" ><td style=\" width: 100px; font-weight: bold; \" >" +
521+ LanguageConsts . StickyNoteDate + ":</td><td>" +
522+ ( ( DateTime ) message . SentOn ) . ToString ( LanguageConsts . DataFormat ) + "</td></tr>" +
523+ Environment . NewLine ;
524+
525+ // Empty line
526+ stickyNoteHeader += "<tr><td colspan=\" 2\" style=\" height: 18px; \" > </td></tr>" + Environment . NewLine ;
527+
528+ // End of table + empty line
529+ stickyNoteHeader += "</table><br/>" + Environment . NewLine ;
530+
531+ body = InjectHeader ( body , stickyNoteHeader ) ;
532+ }
533+ else
534+ {
535+ body = message . BodyText ;
536+
537+ // Sent on
538+ if ( message . SentOn != null )
539+ stickyNoteHeader +=
540+ ( LanguageConsts . StickyNoteDate + ":" ) + ( ( DateTime ) message . SentOn ) . ToString ( LanguageConsts . DataFormat ) + Environment . NewLine ;
541+
542+ body = stickyNoteHeader + body ;
543+ stickyNoteFile = outputFolder + "stickynote" + ".txt" ;
544+ }
545+
546+ // Write the body to a file
547+ File . WriteAllText ( stickyNoteFile , body , Encoding . UTF8 ) ;
548+ result . Add ( stickyNoteFile ) ;
549+ return result ;
550+ }
551+ #endregion
552+
488553 #region GetErrorMessage
489554 /// <summary>
490555 /// Get the last know error message. When the string is empty there are no errors
@@ -702,26 +767,26 @@ private static string GetEmailRecipients(Storage.Message message,
702767 }
703768 #endregion
704769
705- #region InjectOutlookEmailHeader
770+ #region InjectHeader
706771 /// <summary>
707- /// Inject an outlook style header into the email body
772+ /// Inject an outlook style header into the top of the html
708773 /// </summary>
709- /// <param name="eMail "></param>
774+ /// <param name="body "></param>
710775 /// <param name="header"></param>
711776 /// <returns></returns>
712- private string InjectOutlookEmailHeader ( string eMail , string header )
777+ private static string InjectHeader ( string body , string header )
713778 {
714- var temp = eMail . ToUpper ( ) ;
779+ var temp = body . ToUpperInvariant ( ) ;
715780
716781 var begin = temp . IndexOf ( "<BODY" , StringComparison . Ordinal ) ;
717782
718783 if ( begin > 0 )
719784 {
720785 begin = temp . IndexOf ( ">" , begin , StringComparison . Ordinal ) ;
721- return eMail . Insert ( begin + 1 , header ) ;
786+ return body . Insert ( begin + 1 , header ) ;
722787 }
723788
724- return header + eMail ;
789+ return header + body ;
725790 }
726791 #endregion
727792
0 commit comments