PowerTCP Mail for .NET
Textpart Class
Members  Example 




Implements a part used to encapsulate Unicode characters.
Object Model
Textpart ClassContentDisposition ClassContentType ClassHeaderDictionary ClassHeaderField Class
Syntax
Public Class Textpart 
   Inherits Resource
Dim instance As Textpart
public class Textpart : Resource 
public __gc class Textpart : public Resource 
public ref class Textpart : public Resource 
Remarks
ContentType.MediaType is initialized to "text/plain" or "text/html".
Example
This example demonstrates how to add parts to a message. First, a "multipartalternative" part containing two alternative text parts is added. Second, a resource part containing an image is added.
private MailMessage addCustomParts(MailMessage message)
{
    //Add custom header field to message
    message.Headers.Add("X-Alt-Message", new HeaderField("X-Alt-Message", "Message with Alternatives"));

    //Create and add alternative parts to a multipart part
    Textpart part1 = new Textpart("This is alternative 1.");
    part1.Headers.Add("X-Alt", new HeaderField("X-Alt", "Alternative 1"));

    Textpart part2 = new Textpart("This is alternative 2.");
    part2.Headers.Add("X-Alt", new HeaderField("X-Alt", "Alternative 2"));

    Multipart multipart = new Multipart(Multipart.Alternative);
    multipart.Parts.Add(part1);
    multipart.Parts.Add(part2);

    //Add a MultiPart to the MailMessage
    message.Parts.Add(multipart);

    //Add a Resource part to the MailMessage
    Resource resource = new Resource(new FileStream(Application.StartupPath + "\\myImage.jpg", FileMode.Open), "myImage.jpg");
    resource.ContentType = new ContentType("image/jpeg");
    resource.ContentId = "<myImage>";
    message.Parts.Add(resource);
    return message;
}
Private Function addCustomParts(ByVal message As MailMessage) As MailMessage
    'Add custom header field to message
    message.Headers.Add("X-Alt-Message", New HeaderField("X-Alt-Message", "Message with Alternatives"))

    'Create and add alternative parts to a multipart part
    Dim part1 As New Textpart("This is alternative 1.")
    part1.Headers.Add("X-Alt", New HeaderField("X-Alt", "Alternative 1"))

    Dim part2 As New Textpart("This is alternative 2.")
    part2.Headers.Add("X-Alt", New HeaderField("X-Alt", "Alternative 2"))

    Dim multipart As New Multipart(Dart.Mail.Multipart.Alternative)
    multipart.Parts.Add(part1)
    multipart.Parts.Add(part2)

    'Add a MultiPart to the MailMessage
    message.Parts.Add(multipart)

    'Add a Resource part to the MailMessage
    Dim resource As New Resource(New FileStream(Application.StartupPath & "\myImage.jpg", FileMode.Open), "myImage.jpg")
    resource.ContentType = New ContentType("image/jpeg")
    resource.ContentId = "<myImage>"
    message.Parts.Add(resource)
    Return message
End Function
Inheritance Hierarchy

System.Object
   Dart.Mail.Part
      Dart.Mail.Resource
         Dart.Mail.Textpart
            Dart.Mail.Htmlpart

See Also

Reference

Textpart Members
Dart.Mail Namespace


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic