aspNetEmail

Attachment Class

Creates an attachment to be added to an EmailMessage

For a list of all members of this type, see Attachment Members.

System.Object
   Attachment

public class Attachment

Remarks

When using the Attachment class it is highly recommend you create an attachment using one of the class constructors that accept a Filename,a Byte array of data, or a stream. The empty class constructor, Attachment() is meant for advanced email developers. If you use this class constructor, you will be responsible for all formatting and attachment headers.

If you use any other class constructor, the attachment class will automatically create a fully MIME compliant attachment.

Example

[C#]
            EmailMessage msg = new EmailMessage();
            msg.Server = "mail.mycompany.com";
            msg.FromAddress = "me@mycompany.com";
            msg.To = "you@yourcompany.com";
            msg.Subject = "this email has an attachment";
            msg.Body = "what do you think of my logo?";
            
            Attachment a = new Attachment( "logo.gif" );
            msg.AddAttachment( a );
            msg.Send();
            
[Visual Basic]
            Dim msg As New EmailMessage()
            msg.Server = "mail.mycompany.com"
            msg.FromAddress = "me@mycompany.com"
            msg.To = "you@yourcompany.com"
            msg.Subject = "this email has an attachment"
            msg.Body = "what do you think of my logo?"
            
            Dim a As New Attachment("logo.gif")
            msg.AddAttachment(a)
            msg.Send()
            

Requirements

Namespace: aspNetEmail

Assembly: aspNetEmail (in aspNetEmail.dll)

See Also

Attachment Members | aspNetEmail Namespace