Attachment Constructor Home
This page is specific to:.NET Framework Version:2.03.03.54.0
.NET Framework Class Library
Attachment Constructor

Initializes a new instance of the Attachment class.

Overload List

  NameDescription
Public methodAttachment(String)Initializes a new instance of the Attachment class with the specified content string.
Public methodAttachment(Stream, ContentType)Initializes a new instance of the Attachment class with the specified stream and content type.
Public methodAttachment(Stream, String)Initializes a new instance of the Attachment class with the specified stream and name.
Public methodAttachment(String, ContentType)Initializes a new instance of the Attachment class with the specified content string and ContentType.
Public methodAttachment(String, String)Initializes a new instance of the Attachment class with the specified content string and MIME type information.
Public methodAttachment(Stream, String, String)Initializes a new instance of the Attachment class with the specified stream, name, and MIME type information.
Top
See Also

Reference

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.
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
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?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View