aspNetEmail

Attachment.Name Property

The name of the attachment.

public string Name {get; set;}

Remarks

The following example demonstrates an advanced technique for createing an attachment.

If possible, use one of the other Attachment class constructors.

Example

[C#]
            EmailMessage msg = new EmailMessage();
            msg.Server = "mail.mycompany.com";
            msg.FromAddress = "me@mycompany.com";
            msg.To = "you@yourcompany.com";
            msg.Subject = "this is an advanced sample";
            msg.Body = "this email contains an inline attachment.";
            
            Attachment a = new Attachment();
            a.Name = "MyAsciiText.txt";
            a.ContentDisposition = "inline";
            a.ContentTransferEncoding = MailEncoding.Bit7;
            a.ContentType = "text/plain";
            a.Contents = "this is my inline attachment";
            
            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 is an advanced sample"
            msg.Body = "this email contains an inline attachment."
            
            Dim a As New Attachment()
            a.Name = "MyAsciiText.txt"
            a.ContentDisposition = "inline"
            a.ContentTransferEncoding = MailEncoding.Bit7
            a.ContentType = "text/plain"
            a.Contents = "this is my inline attachment"
            
            msg.AddAttachment(a)
            msg.Send()
            

See Also

Attachment Class | aspNetEmail Namespace