PowerTCP Mail for .NET
Attachments Property
See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace > MessageStream Class : Attachments Property




Gets a collection containing all recursive attachments contained within the message

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Attachments As Attachments
Visual Basic (Usage)Copy Code
Dim instance As MessageStream
Dim value As Attachments
 
value = instance.Attachments
C# 
public Attachments Attachments {get;}
Managed Extensions for C++ 
public: __property Attachments* get_Attachments();
C++/CLI 
public:
property Attachments^ Attachments {
   Attachments^ get();
}

Property Value

Attachments collection.

Example

The following example demonstrates creating a basic MIME message with a single attachment.
Visual BasicCopy Code
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.

' Create a MessageStream object
Dim msg As New MessageStream()

' Add a normal recipient
msg.To.Add(New MailAddress("you@test.com"))

' Add a CC recipient
msg.CC.Add(New MailAddress("you2@test.com"))

' Add a BCC recipient
msg.BCC.Add(New MailAddress("you3@test.com"))

' Specify the sender
msg.From = New MailAddress("me@test.com")

' Specify the subject
msg.Subject = "Hello"

' Add some text to the message.
msg.Text = "Hi everyone. How are ya doing?"

' Add an attachment
msg.Attachments.Add("C:\files\graph.jpg")

' 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.

// Create a MessageStream object
MessageStream msg = new MessageStream();

// Add a normal recipient
msg.To.Add(new MailAddress("you@test.com"));

// Add a CC recipient
msg.CC.Add(new MailAddress("you2@test.com"));

// Add a BCC recipient
msg.BCC.Add(new MailAddress("you3@test.com"));

// Specify the sender
msg.From = new MailAddress("me@test.com");

// Specify the subject
msg.Subject = "Hello";

// Add some text to the message.
msg.Text = "Hi everyone. How are ya doing?";

// Add an attachment
msg.Attachments.Add("C:\\files\\graph.jpg");

// Specify the server
smtp1.Server = "mail.test.com";

// Send the message
smtp1.Send(msg);

Remarks

This property is an Attachments collection which reflects all attachments in this message that are held at any layer of the recursive message structure. Essentially, this collection is the combination of all items held in the MessageStream.NonMime.Attachments collection (non-MIME attachments), the MessageStream.Parts.Attachments collection (MIME attachments), and recursive attachments contained within all the layers of MessageStream.Parts.Complex. The end result is that this collection contains every attachment that exists at any level in the message. You can also get these attachments by referencing the appropriate collection. For example, if you only care about accessing MIME attachments, simply access the MessageStream.Parts.Attachments collection and bypass the MessageStream.Attachments collection.

If you wish to add attachments to this collection using MessageStream.Attachments.Add, they should be of type MimeAttachmentStream.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.