PowerTCP Mail for .NET
AttachmentStream Constructor(String)
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > AttachmentStream Class > AttachmentStream Constructor : AttachmentStream Constructor(String)




fileName
The name of the file to add as an attachment.
Initializes a new AttachmentStream with the file data contained in the file specified by fileName.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal fileName As String _
)
Visual Basic (Usage)Copy Code
Dim fileName As String
 
Dim instance As New AttachmentStream(fileName)
C# 
public AttachmentStream( 
   string fileName
)
Managed Extensions for C++ 
public: AttachmentStream( 
   string* fileName
)
C++/CLI 
public:
AttachmentStream( 
   String^ fileName
)

Parameters

fileName
The name of the file to add as an attachment.

Example

The following example demonstrates creating a basic non-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"))

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

' Specify the subject
msg.Subject = "Test"

' Add Non-MIME text
msg.NonMime.Text = "Hello. How are you"

' Add a Non-MIME, Uuencoded attachment.
msg.NonMime.Attachments.Add(New AttachmentStream("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"));

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

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

// Add Non-MIME text
msg.NonMime.Text = "Hello. How are you";

// Add a Non-MIME, Uuencoded attachment.
msg.NonMime.Attachments.Add(new AttachmentStream("C:\\files\\graph.jpg"));

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

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

Remarks

Use this constructor if you wish to create an AttachmentStream from a file on disk.

When creating an AttachmentStream using this constructor, the AttachmentStream.FileName property will be everything after the last "/" OR "\\" ("\" in VB) in fileName.

When creating an AttachmentStream the data will always be read out as a Uuencoded attachment. For this reason, a new AttachmenStream will be created with AttachmentStream.MimeEncoding = ContentEncoding.Uuencode. Changing this property could result in incorrect message structure.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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