
| Visual Basic (Declaration) | |
|---|---|
<DefaultMemberAttribute("Item")> Public Class Parts Inherits System.Collections.ArrayList | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Parts | |
| C# | |
|---|---|
[DefaultMemberAttribute("Item")] public class Parts : System.Collections.ArrayList | |
| Managed Extensions for C++ | |
|---|---|
[DefaultMemberAttribute("Item")] public __gc class Parts : public System.Collections.ArrayList | |
| C++/CLI | |
|---|---|
[DefaultMemberAttribute("Item")] public ref class Parts : public System.Collections.ArrayList | |
The following example demonstrates the many ways a MIME message can be created.
| Visual Basic | Copy Code |
|---|---|
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail" ' at the top of your class. In addition, import System.IO, as a FileStream will be used. ' Create a MessageStream object Dim msg As New MessageStream() ' Add a normal recipient msg.To.Add(New MailAddress("you@test.com")) ' Specify the sender msg.From = New MailAddress("me@test.com") ' Specify the subject msg.Subject = "Test" ' Add a MIME attachment msg.Parts.Attachments.Add(New MimeAttachmentStream("C:\files\graph.bmp")) ' Add some MIME text (Setting MessageStream.Text also does this). msg.Parts.Simple.Add(New MessagePartStream("More text here")) ' Create a complex MIME part from a stored message. msg.Parts.Complex.Add(New MessageStream(New FileStream("C:\\message.eml", FileMode.Open))) ' Create a custom MIME boundary to use. (the component will ' create a default MIME boundary to use if this isn't specified) msg.MimeBoundary = "----MyBoundary-----" ' Override automatic date setting msg.Date = "" ' Add a header line. msg.Header.Add(HeaderLabelType.Organization, "My Organization") ' Now add a custom header line. msg.Header.Add("X-My-Field: My Value") ' Specify the server Smtp1.Server = "mail.test.com" ' Send the message Smtp1.Send(msg) | |
| C# | Copy Code |
|---|---|
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;" // at the top of your class. In addition, import System.IO, as a FileStream will be used.\ // Create a MessageStream object MessageStream msg = new MessageStream(); // Add a normal recipient msg.To.Add(new MailAddress("you@test.com")); // Specify the sender msg.From = new MailAddress("me@test.com"); // Specify the subject msg.Subject = "Test"; // Add a MIME attachment msg.Parts.Attachments.Add(new MimeAttachmentStream("C:\\files\\graph.bmp")); // Add some MIME text (MessageStream.Text also does this). msg.Parts.Simple.Add(new MessagePartStream("More text here")); // Create a complex MIME part from a stored message. msg.Parts.Complex.Add(new MessageStream(new FileStream("C:\\message.eml", FileMode.Open))); // Create a custom MIME boundary to use. (the component will // create a default MIME boundary to use if this isn't specified) msg.MimeBoundary = "----MyBoundary-----"; // Override automatic date setting msg.Date = ""; // Add a header line. msg.Header.Add(HeaderLabelType.Organization, "My Organization"); // Now add a custom header line. msg.Header.Add("X-My-Field: My Value"); // Specify the server smtp1.Server = "mail.test.com"; // Send the message smtp1.Send(msg); | |
The Parts class contains all MIME-related collections for the message. The collections are as follows:
- Parts.Attachments, a collection of MimeAttachmentStreams, contains all MIME attachments in the message.
- Parts.Simple, a collection of MessagePartStreams, contains all simple inline MIME parts in the message.
- Parts.Complex, a collection of MessageStreams, contains all complex MIME parts in the message. A complex part is either a mail message (which could then be used as an initializer for a new MessageStream object) or has multi-part structure.
The Parts class is accessible through MessageStream.Parts. All non-Mime parts of the message are accessible through MessageStream.NonMime.
This collection contains all streams sent inside MIME partitions in this message. Advanced users may wish to add different types of Streams than those supported at the basic level to this object.
System.Object
System.Collections.ArrayList
Dart.PowerTCP.Mail.Parts
Target Platforms: Microsoft .NET Framework 2.0