| Author |  | 
      
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          I download and saved an attachment that came through in this format.  Is there a way for MailBee IMAP to convert this file to something readible.  If I can see the encoding is Application/MS-TNEF I should be able to convert it to .rtf or something.
           | Posted: 07 July 2009 at 9:07am | IP Logged |   |  
           | 
 |  
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          In order to extract files from winmail.dat, GetAttachmentsFromTnef method of Attachment object should be used. You'll find an example here.
           | Posted: 07 July 2009 at 1:09pm | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          Its beautiful
           | Posted: 08 July 2009 at 5:48am | IP Logged |   |  
           | 
 |    | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          I need to get it in byte[] stream.  I have been using GetData() but that does not seem to work with GetAttachmentsFromTnef()
           | Posted: 08 July 2009 at 12:06pm | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          GetAttachmentsFromTnef method returns AttachmentCollection object. Instead of using SaveAll method, try retrieving attachments from TNEF separately (bw stands for BinaryWriter you have set up):
           | Posted: 09 July 2009 at 1:58am | IP Logged |   |  
           | 
 |  
 
 
| Code: 
 
    
    | 
      
       | foreach (Attachment file in msg.Attachments) {
 if (file.IsTnef)
 {
 tnef_files = file.GetAttachmentsFromTnef();
 foreach (Attachment tf in tnef_files)
 {
 bw.Write(tf.GetData());
 }
 }
 |  |  |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          thanks.  I saved the file to the database and then tried to download it again from the database table.  It will not open, I think because the contenttype is application/octet-stream.  What is supposed to open that content type?
           | Posted: 09 July 2009 at 4:49am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          "application/octet-stream" stands for binary file of unknown MIME type. You might want to retrieve original content type and file name from tf. along with data itself.
           | Posted: 09 July 2009 at 5:27am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          http://support.microsoft.com/kb/224817
           | Posted: 09 July 2009 at 5:45am | IP Logged |   |  
           | 
 |  says there is a contenttype="text/plain" in there as well.  I would be happy to get that.  Is there a way to go through the message and get all "text/plain" content types?
 
 foreach (MailBee.Mime.Attachment tf in attach.GetAttachmentsFromTnef())
 {
 TicketAttachmentObj ta = new TicketAttachmentObj();
 ta.ContentType = tf.ContentType;
 ta.FileName = tf.Filename + ".msg";
 ta.FileContents = tf.GetData();
 ta.FileSize = attach.Size;
 ta.UploadedByUserId = EmailContact.UserId;
 ta.UploadedDate = DateTime.Now;
 ta.TicketId = ticketId;
 ta.Description = "TNEF File";
 ta.Save();
 }
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Andrew AfterLogic Support
 
  
 
 Joined: 28 April 2006
 Location: United States
 Online Status: Offline
 Posts: 1189
 | 
          Retrieving text bodies from TNEF files is not supported yet. Moreover, most third-party (non-Microsoft) TNEF parsers support retrieving attachments only. This is because TNEF files contain text bodies extremely rarely, usually, Outlook places only attachments there.
           | Posted: 09 July 2009 at 5:49am | IP Logged |   |  
           | 
 |  
 Best regards,
 Andrew
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          BTW, there is in error in the code that prevented download - should be
           | Posted: 09 July 2009 at 6:19am | IP Logged |   |  
           | 
 |  ta.FileSize = tf.Size;
 
 Anyway, when I save the file as .msg and try to open it, I get this message:
 
 cannot start microsoft outlook.  Can't open file C:\whereIsaved\myfile.msg.  The file may exist, but you do not have permission to open it, or it may be open in another program.  Right-click the folder that contains the file, and then click Properties to check your permissions folder.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          
           | Posted: 09 July 2009 at 6:32am | IP Logged |   |  
           | 
 |  
| Quote: 
 
    
    | 
      
       | when I save the file as .msg |  |  |  
 Not sure if I understood this one. What exactly you're trying to save as .msg?
 
 
 
| Quote: 
 
    
    | 
      
       | cannot start microsoft outlook. Can't open file C:\whereIsaved\myfile.msg. The file may exist, but you do not have permission to open it, or it may be open in another program. Right-click the folder that contains the file, and then click Properties to check your permissions folder. |  |  |  Did you try to follow these recommendations? The file may indeed be locked by other process.
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          what extension do you suggest then?  I followed all the recommendations but still cannot get outlook to open the tnef file.  When you save the file there is no extension in the tf.filename.  I tried .eml and outlook express opens it, but there is some stuff garbled.
           | Posted: 09 July 2009 at 6:35am | IP Logged |   |  
           | 
 |  
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Still no answer to this one:
           | Posted: 09 July 2009 at 6:41am | IP Logged |   |  
           | 
 |  
 
| Quote: 
 
    
    | 
      
       | What exactly you're trying to save as .msg? |  |  |  
 If you're retrieving "text/plain", why not calling it .txt file?
 
 --
 Regards,
 Igor, AfterLogic Support
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          the .tnef file that has  contenttype=application/octet-stream
           | Posted: 09 July 2009 at 6:51am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          мы говорим на разных языках
           | Posted: 09 July 2009 at 6:59am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          It's really not clear for us what exactly you're trying to save and for what purpose. E.g.: what do you mean of ".tnef file"? It's how winmail.dat container itself is called, and when you get plain text from there, it will be nothing but a plain text.
           | Posted: 09 July 2009 at 7:18am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 
 NB: Please feel free to use our HelpDesk if you'd like to discuss the issue in Russian; this forum is public and most readers do not understand Russian.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | zedekiah Groupie
 
  
 
 Joined: 24 June 2009
 Location: United States
 Online Status: Offline
 Posts: 44
 | 
          The file exists as a .msg in the filesystem.  When I attach that file to an email and then use MailBee to save the attachment to the database it never can display correctly.  I am beginning to think there must be an attachment within an attachment or something.  It is a email within an email within an email.
           | Posted: 09 July 2009 at 10:48am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Andrew AfterLogic Support
 
  
 
 Joined: 28 April 2006
 Location: United States
 Online Status: Offline
 Posts: 1189
 | 
          
           | Posted: 10 July 2009 at 12:04am | IP Logged |   |  
           | 
 |  
| Quote: 
 
    
    | 
      
       | The file exists as a .msg in the filesystem. |  |  |  
 Let's call it "original_msg.msg".
 
 
 
| Quote: 
 
    
    | 
      
       | When I attach that file to an email |  |  |  
 Let's call it "container_msg".
 
 
 
| Quote: 
 
    
    | 
      
       | and then use MailBee to save the attachment to the database it never can display correctly. |  |  |  
 According to the previous two statements, you're trying to save "original_msg.msg" to the database because it's an attachment of "container_msg".
 
 So, you're trying to display "original_msg.msg" obtained from the database, but it's not clear how you're trying to display it. Only Office Outlook is able to display MSG files correctly.
 
 If you don't use Office Outlook, you should convert the MSG file to EML format before displaying. Anyway, it's not completely clear how this is connected with obtaining something from TNEF.
 
 If you provided us with clear description of the issue, we'd be able to help you. We recommend to continue the discussion through our Helpdesk because understanding this thread would too complex for other users.
 
 BTW, perhaps, it'd be useful to prepare a diagram with messages hierarchy and with description/purpose of each hierarchy level. Until we get clear picture in our minds, we'd be not able to help you.
 
 Best regards,
 Andrew
 | 
       
        | Back to Top |     | 
       
       
        |  |