MailBee.NET Objects 4.0

Attachment.IsTnef Property

Indicates if the attachment is MS-TNEF (winmail.dat) container which can have other attachments inside.

public bool IsTnef {get;}

Property Value

true if the attachment has MS-TNEF format; otherwise, false.

Remarks

Transport Neutral Encapsulation Format or TNEF is a Microsoft data format used by Microsoft Outlook and Microsoft Exchange Server. TNEF attachments are usually named winmail.dat or win.dat.

TNEF is not a common standard so that most mail clients do not natively support it. However, MailBee allows the developer to extract attachments from TNEF containers into AttachmentCollection using GetAttachmentsFromTnef method and then treat them like any other attachments.

Example

This sample loads the message from .EML file and saves all TNEF-formatted attachments to disk (if any).

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// The actual code (put it into a method of your class)

// Load the message from file.
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\mstnef.eml");

// For every attachment...
foreach (Attachment attach in msg.Attachments)
{
    // ...when the attachment is TNEF...
    if (attach.IsTnef)
    {
        // ...extract all the files from it and save them to the folder.
        attach.GetAttachmentsFromTnef().SaveAll(@"C:\Temp");
    }
}
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

' The actual code (put it into a method of your class)

' Load the message from file.
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\mstnef.eml")

' For every attachment...
For Each attach As Attachment In msg.Attachments
    ' ...when the attachment is TNEF...
    If (attach.IsTnef) Then
        ' ...extract all the files from it and save them to the folder.
        attach.GetAttachmentsFromTnef().SaveAll("C:\Temp")
    End If
Next

See Also

Attachment Class | MailBee.Mime Namespace | GetAttachmentsFromTnef