Home
Library
Learn
Downloads
Support
Community
Forums
MSDN Library
.NET Development
.NET Framework 3.5
.NET Framework Class Library
System.Net.Mail Namespace
Attachment Class
Attachment Constructor
Attachment Constructor (String)
Attachment Constructor (Stream, ContentType)
Attachment Constructor (Stream, String)
Attachment Constructor (String, ContentType)
Attachment Constructor (String, String)
Attachment Constructor (Stream, String, String)
Related Links
Attachment Members
Attachment Methods
Attachment Properties
Attachment Constructor
This page is specific to:
.NET Framework Version:
2.0
3.0
3.5
4.0
.NET Framework Class Library
Attachment Constructor
Initializes a new instance of the
Attachment
class.
Overload List
Name
Description
Attachment(String)
Initializes a new instance of the
Attachment
class with the specified content string.
Attachment(Stream, ContentType)
Initializes a new instance of the
Attachment
class with the specified stream and content type.
Attachment(Stream, String)
Initializes a new instance of the
Attachment
class with the specified stream and name.
Attachment(String, ContentType)
Initializes a new instance of the
Attachment
class with the specified content string and
ContentType
.
Attachment(String, String)
Initializes a new instance of the
Attachment
class with the specified content string and MIME type information.
Attachment(Stream, String, String)
Initializes a new instance of the
Attachment
class with the specified stream, name, and MIME type information.
Top
See Also
Reference
Attachment Class
Attachment Members
System.Net.Mail Namespace
Community Content
Some notes about using Streams
Added by:
cathexis
First of all, the Stream that you supply to an attachment is not read until you actually send a message. That should make sense enough, but sometimes it's easy to forget. If your stream relies on some other resource that was disposed of by the time the message is sent, the client will fail to send your message.
Secondly, if you are writing into a Stream that will later be read by an Attachment, make sure you set the Position back to 0. Otherwise, you may end up with zero-length attachments even though your stream has data! Attachment does not appear to rewind the Stream for you; it reads from whatever position the Stream is currently at.
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Yes
No
Do you like the tabbed code blocks?
Yes
No
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
x
Classic
Lightweight Beta
ScriptFree
Switch View