aspNetEmail

Attachment.FileName Property

File name of the attachment.

public string FileName {get; set;}

Example

[C#]
            EmailMessage m = new EmailMessage("127.0.0.1" );
            m.From = "me@mycompany.com";
            m.To = "you@yourcompany.com";
            m.Subject = "testing email";
            m.Body = "the body text goes here...";
            
            //enable logging for any troubleshooting problems
            m.Logging = true;
            m.LogPath = "c:\\email.log";
            
            //create an attachment
            byte[] data = GetSqlServerDocument(); //a method that gets data from sql server
            Attachment a = new Attachment();
            a.Data = data;
            a.Name = "report.txt";
            a.FileName = "report.txt";
            
            m.AddAttachment( a );
            
            //send
            m.Send();
            
[VB.NET]
            
            Dim m As New EmailMessage("127.0.0.1")
            
            m.From = "me@mycompany.com"
            m.To = "you@yourcompany.com"
            m.Subject = "testing email"
            m.Body = "the body text goes here..."
            
            'enable logging for any troubleshooting problems
            m.Logging = True
            m.LogPath = "c:\email.log"
            
            'create an attachment
            Dim data As Byte() = GetSqlServerDocument() 'a method that gets data from sql server
            Dim a As New Attachment()
            a.Data = data
            a.Name = "report.txt"
            a.FileName = "report.txt"
            
            m.AddAttachment(a)
            
            'send
            m.Send()
            
            

See Also

Attachment Class | aspNetEmail Namespace