An Attachment can be added from a file, a stream, or a byte array. When adding a file as an attachment, the existing file name from the Attachment.FileName property will be used by default. But for byte array and stream, it is compulsory to specify the file name. The attachment filename extension will decide the default MIME content type of the particular file.
Below is an example of using a stream as an attachment.
[Visual Basic]
Dim ptMessage As PlainTextMessage = New PlainTextMessage(fromAddress,toAddress,"Mail with Stream Attachment","Files Attached")
' Create the file Stream
Dim MyStream As System.IO.FileStream = New System.IO.FileStream("ceTe Logo.jpg",System.IO.FileMode.Open)
'Attach the file stream
ptMessage.Attachments.Add(MyStream, "ceTe Logo.jpg")
ptMessage.Send(smtpServer)
[C#]
PlainTextMessage ptMessage = new PlainTextMessage ( fromAddress, toAddress, "Mail with Stream Attachment", "Files Attached" );
// Create the file Stream
System.IO.FileStream fileStream = new System.IO.FileStream( "ceTe Logo.jpg", System.IO.FileMode.Open );
//Attach the file stream
ptMessage.Attachments.Add( fileStream, "ceTe Logo.jpg" );
ptMessage.Send( smtpServer );
| See Also |
Attachment Class | PlainTextMessage Class | Programming with FireMail for .NET

