Creating a MimeMessage message from a file |
To create a MimeMessage from a file, construct a new MimeMessage instance and pass the byte array contents of the file as the argument.
Example This example creates a new MimeMessage instance from data read from a file. It is assumed that the filename value is a valid file.
[C#] FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); byte[] data = r.ReadBytes((int)fs.Length); fs.Close(); MimeMessage message = new MimeMessage(data);
[Visual Basic] Dim message As MimeMessage = Nothing Dim fs As New FileStream(filename, FileMode.Open, FileAccess.Read) Dim r As New BinaryReader(fs) Dim data As Byte() = r.ReadBytes(fs.Length) fs.Close() message = New MimeMessage(data)
|