Parses the winmail.dat (TNEF attachment).
[Visual Basic]
Public Function ParseTNEF( _
data() As Byte, _
includeRTFBody As Boolean
) As Attachment()
[C#]
public Attachment[] ParseTNEF(
byte[] data,
bool includeRTFBody
);
[C++]
public: array<Attachment^> ParseTNEF(
array<unsigned char> data,
bool includeRTFBody
);
[JScript]
public function ParseTNEF(
data : Byte[],
includeRTFBody : Boolean
) : Attachment[];
Parameters
Return Value
Example
[Visual Basic, C#] The following example demonstrates how to deal with the winmail.dat attachment. To get the full samples of EAGetMail, please refer to Samples section.
[VB - Parse winmail.dat (TNEF)]
Dim oMail As New Mail("TryIt")
oMail.Load("c:\test.eml", False)
Dim atts() As Attachment = oMail.Attachments
Dim tempFolder As String = "c:\temp"
Dim count As Integer = atts.Length
If (Not System.IO.Directory.Exists(tempFolder)) Then
System.IO.Directory.CreateDirectory(tempFolder)
End If
For i As Integer = 0 To count - 1
Dim att As Attachment = atts(i)
'this attachment is in OUTLOOK RTF format, decode it here.
If (String.Compare(att.Name, "winmail.dat") = 0) Then
Dim tatts() As Attachment
Try
tatts = Mail.ParseTNEF(att.Content, True)
Dim y As Integer = tatts.Length
For x As Integer = 0 To y - 1
Dim tatt As Attachment = tatts(x)
Dim tattname As String = String.Format("{0}\{1}", tempFolder, tatt.Name)
tatt.SaveAs(tattname, True)
Next
Catch ep As Exception
MessageBox.Show(ep.Message)
End Try
Else
Dim attname As String = String.Format("{0}\{1}", tempFolder, att.Name)
att.SaveAs(attname, True)
End If
Next
[C# - Parse winmail.dat (TNEF)]
Mail oMail = new Mail("TryIt");
oMail.Load("c:\\test.eml", false);
Attachment [] atts = oMail.Attachments;
int count = atts.Length;
string tempFolder = "c:\\temp";
if(!System.IO.Directory.Exists(tempFolder))
System.IO.Directory.CreateDirectory(tempFolder);
for(int i = 0; i < count; i++)
{
Attachment att = atts[i];
//this attachment is in OUTLOOK RTF format, decode it here.
if(String.Compare(att.Name, "winmail.dat") == 0)
{
Attachment[] tatts = null;
try
{
tatts = Mail.ParseTNEF(att.Content, true);
}
catch(Exception ep)
{
MessageBox.Show(ep.Message);
continue;
}
int y = tatts.Length;
for(int x = 0; x < y; x++)
{
Attachment tatt = tatts[x];
string tattname = String.Format("{0}\\{1}", tempFolder, tatt.Name);
tatt.SaveAs(tattname , true);
}
continue;
}
string attname = String.Format("{0}\\{1}", tempFolder, att.Name);
att.SaveAs(attname , true);
}
Remarks
See Also
Online Tutorials
Parse Email in C# - Tutorial
Parse winmail.dat(TNEF) in C# - Tutorial
Parse Email in VB.NET - Tutorial
Parse winmail.dat(TNEF) in VB.NET - Tutorial
Parse Email in C++/CLI - Tutorial
Parse winmail.dat(TNEF) in C++/CLI - Tutorial