Author |
|
hr-pb Newbie
Joined: 06 December 2008
Online Status: Offline Posts: 12
|
Posted: 02 June 2009 at 4:18am | IP Logged
|
|
|
Hi,
how to extract attachments from TNEF containers into AttachmentCollection using GetAttachmentsFromTnef method and then treat them like any other attachments ?
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 02 June 2009 at 4:41am | IP Logged
|
|
|
Not sure we understood the problem. Please take a look at the following code (found here):
Code:
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\mstnef.eml");
foreach (Attachment attach in msg.Attachments)
{
if (attach.IsTnef)
{
attach.GetAttachmentsFromTnef().SaveAll(@"C:\Temp");
}
} |
|
|
This code loads message from file, retrieves all the attachments found in message, every attachment is analyzed and in case if it's TNEF attachment, its content is extracted with GetAttachmentsFromTnef method, so you get attachments collection you can process the way you need.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
hr-pb Newbie
Joined: 06 December 2008
Online Status: Offline Posts: 12
|
Posted: 02 June 2009 at 5:57am | IP Logged
|
|
|
hmmm...
I have file winmail.dat , I need to extract attachments from this file, but I don't want save them all at once.I need to save one by one.
|
Back to Top |
|
|
hr-pb Newbie
Joined: 06 December 2008
Online Status: Offline Posts: 12
|
Posted: 02 June 2009 at 5:58am | IP Logged
|
|
|
here :
http://www.afterlogic.com/mailbee_net/docs/MailBee.Mime.Atta chment.IsTnef.html
"(...)However, MailBee allows the developer to extract attachments from TNEF containers into AttachmentCollection using GetAttachmentsFromTnef method and then treat them like any other attachments"
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 02 June 2009 at 6:49am | IP Logged
|
|
|
Well, using SaveAll was just an example of what you can do with attachment collection. If you need to process them one by one, you can do it as follows:
Code:
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\mstnef.eml");
foreach (Attachment attach in msg.Attachments)
{
if (attach.IsTnef)
{
AttachmentCollection coll = attach.GetAttachmentsFromTnef();
foreach (Attachment att in coll)
{
// e.g.:
// att.Save(@"C:\Temp\" + att.Filename, true);
}
}
} |
|
|
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
hr-pb Newbie
Joined: 06 December 2008
Online Status: Offline Posts: 12
|
Posted: 02 June 2009 at 6:51am | IP Logged
|
|
|
thx
|
Back to Top |
|
|
hr-pb Newbie
Joined: 06 December 2008
Online Status: Offline Posts: 12
|
Posted: 16 June 2009 at 3:26am | IP Logged
|
|
|
I have mail with winmail.dat file...I have error message : "Unexpected end of TNEF stream",how to resolve this problem ?
my code :
if (attach.IsTnef)
{
AttachmentCollection coll = attach.GetAttachmentsFromTnef();//error
}
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 16 June 2009 at 3:32am | IP Logged
|
|
|
In order to let us help you on this, please provide us with the email message you're trying to process.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|