MimePartCollectionItem Property (String) |
Gets the MIME part by the specified Content-Type.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public MimePart this[
string name
] { get; }
Public ReadOnly Default Property Item (
name As String
) As MimePart
Get
Parameters
- name
- Type: SystemString
The Content-Type of the MIME part to be searched in the collection.
Property Value
Type:
MimePart
A
MimePart object which has
ContentType value equal to the specified
name;
or a null reference (
Nothing in Visual Basic) if the collection does not contain such
MimePart objects.
Remarks The search is case-sensitive. For instance, if name is text/plain while
ContentType of the MIME part is TEXT/PLAIN, that MimePart
object will still be returned.
If multiple MimePart objects in the collection meet the specified search condition, only the first found object
will be returned.
Examples This sample loads the message from .EML file and displays the size of XML body of the message if any.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
MimePart xmlPart = msg.MimePartTree.GetAllParts()["text/xml"];
if (xmlPart != null)
{
Console.WriteLine(xmlPart.Size.ToString());
}
else
{
Console.WriteLine("No such MimePart.");
}
Imports MailBee
Imports MailBee.Mime
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
Dim xmlPart As MimePart = msg.MimePartTree.GetAllParts()("text/xml")
If Not xmlPart Is Nothing Then
Console.WriteLine(xmlPart.Size.ToString())
Else
Console.WriteLine("No such MimePart.")
End If
See Also