Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: TNEF Winmail.dat Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 07 July 2009 at 9:07am | IP Logged Quote zedekiah

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.
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 07 July 2009 at 1:09pm | IP Logged Quote Igor

In order to extract files from winmail.dat, GetAttachmentsFromTnef method of Attachment object should be used. You'll find an example here.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 08 July 2009 at 5:48am | IP Logged Quote zedekiah

Its beautiful
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 08 July 2009 at 12:06pm | IP Logged Quote zedekiah

I need to get it in byte[] stream. I have been using GetData() but that does not seem to work with GetAttachmentsFromTnef()
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 09 July 2009 at 1:58am | IP Logged Quote Igor

GetAttachmentsFromTnef method returns AttachmentCollection object. Instead of using SaveAll method, try retrieving attachments from TNEF separately (bw stands for BinaryWriter you have set up):

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 View Igor's Profile Search for other posts by Igor
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 4:49am | IP Logged Quote zedekiah

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?
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 09 July 2009 at 5:27am | IP Logged Quote Igor

"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.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 5:45am | IP Logged Quote zedekiah

http://support.microsoft.com/kb/224817
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 View zedekiah's Profile Search for other posts by zedekiah
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 09 July 2009 at 5:49am | IP Logged Quote Andrew

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.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 6:19am | IP Logged Quote zedekiah

BTW, there is in error in the code that prevented download - should be
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 View zedekiah's Profile Search for other posts by zedekiah
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 09 July 2009 at 6:32am | IP Logged Quote Igor

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 View Igor's Profile Search for other posts by Igor
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 6:35am | IP Logged Quote zedekiah

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.
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 09 July 2009 at 6:41am | IP Logged Quote Igor

Still no answer to this one:
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 View Igor's Profile Search for other posts by Igor
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 6:51am | IP Logged Quote zedekiah

the .tnef file that has contenttype=application/octet-stream
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 6:59am | IP Logged Quote zedekiah

мы говорим на разных языках
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 09 July 2009 at 7:18am | IP Logged Quote Igor

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.

--
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 View Igor's Profile Search for other posts by Igor
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 09 July 2009 at 10:48am | IP Logged Quote zedekiah

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.
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 10 July 2009 at 12:04am | IP Logged Quote Andrew

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 View Andrew's Profile Search for other posts by Andrew
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide