Creates an attachment to be added to an EmailMessage
For a list of all members of this type, see Attachment Members.
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.
[C#] EmailMessage msg = new EmailMessage(); msg.Server = "mail.mycompany.com"; msg.FromAddress = "firstname.lastname@example.org"; msg.To = "email@example.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 = "firstname.lastname@example.org" msg.To = "email@example.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()
Assembly: aspNetEmail (in aspNetEmail.dll)