TextBodyPartCollectionAdd Method (String, HeaderCollection, Boolean) |
Creates a new text body part having the specified parameters and appends it to the collection.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public TextBodyPart Add(
string contentType,
HeaderCollection customHeaders,
bool noDefaultHeaders
)
Public Function Add (
contentType As String,
customHeaders As HeaderCollection,
noDefaultHeaders As Boolean
) As TextBodyPart
Parameters
- contentType
- Type: SystemString
A string specifying the content type of the text part to be created. - customHeaders
- Type: MailBee.MimeHeaderCollection
A reference to the collection of user-defined headers to be placed into the header section of the text part,
a null reference (Nothing in Visual Basic) if no user-defined headers available. - noDefaultHeaders
- Type: SystemBoolean
Indicates whether to add the standard headers.
Return Value
Type:
TextBodyPartA reference to the newly added text body part.
Exceptions Remarks
By default, the newly created text part will contain Content-Type and (optionally) Content-Transfer-Encoding headers.
If noDefaultHeaders was true, these headers will not be added and contentType value will be ignored.
Examples This sample creates a new message, sets plain-text body and alternative XML body with user-defined header, and saves it to disk.
using MailBee;
using MailBee.Mime;
MailMessage msg = new MailMessage();
msg.BodyPlainText = "See XML body";
HeaderCollection userDefined = new HeaderCollection();
userDefined.Add("Content-Class", "document", true);
msg.BodyParts.Add("text/xml", userDefined, false).Text = "<?xml version=\"1.0\" ?>";
msg.SaveMessage(@"C:\Docs\TestMail.eml");
Imports MailBee
Imports MailBee.Mime
Dim msg As MailMessage = New MailMessage
msg.BodyPlainText = "See XML body"
Dim userDefined As HeaderCollection = New HeaderCollection
userDefined.Add("Content-Class", "document", True)
msg.BodyParts.Add("text/xml", userDefined, False).Text = "<?xml version=""1.0"" ?>"
msg.SaveMessage("C:\Docs\TestMail.eml")
See Also