
Signature
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--
The following article contains code to create attachments, you could perhaps
modify it to use a stream instead.
http://www.eggheadcafe.com/articles/20030316.asp
I am guessing there is code somewhere that writes these flat files. So,
instead of writing the files, pass the stream to the above code. Hope that
helps.

Signature
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
> I have an ASP 3 application that I am converting to and improving with
> ASP.NET. This application creates two temporary flat files and appends them
[quoted text clipped - 4 lines]
>
> Is there an example or description that you can recommend?
Thom Little - 07 Mar 2005 20:28 GMT
That is a very interesting article and probably helpful for solving a larger
problem that I have.
I currently have the revised application written and tested to use Smtp. It
is invoked with a form from any HTTP page. The remaining issue is to create
and attach two files. I am looking for an example that allows me to attach
"files" that are not physically resident on disk. Perhaps this is a
capability provided by the Cache?
The reason is that writing them to disk makes it necessary to have a
dedicated folder (temp) that has permissions adjusted for ASP.NET access.
This makes it cumbersome to setup when moved to a server under some else's
control.

Signature
-- Thom Little -- www.tlanet.net -- Thom Little Associates, Ltd.
--
> The following article contains code to create attachments, you could
> perhaps
[quoted text clipped - 5 lines]
> instead of writing the files, pass the stream to the above code. Hope that
> helps.
[MSFT] - 08 Mar 2005 02:19 GMT
Hello Thom,
The object in ASP.NET cache cannot be used as actual file for amail
attachment. I think Manohar's suggestion is the right way to resolve the
problem. You can take a look at following code in the sample he recommended:
MailAttachment a = o as MailAttachment;
byte[] binaryData;
if(a!=null)
{
FileInfo f = new FileInfo(a.Filename);
sb.Append("--unique-boundary-1\r\n");
sb.Append("Content-Type: application/octet-stream; file=" + f.Name +
"\r\n");
sb.Append("Content-Transfer-Encoding: base64\r\n");
sb.Append("Content-Disposition: attachment; filename=" + f.Name + "\r\n");
sb.Append("\r\n");
FileStream fs = f.OpenRead();
binaryData = new Byte[fs.Length];
long bytesRead = fs.Read(binaryData, 0, (int)fs.Length);
fs.Close();
string base64String = System.Convert.ToBase64String(binaryData,
0,binaryData.Length);
..
Above code add an attachment to the mail and data is in the byte array.
Based on the sample, you can load your data in a byte array or stream, and
then add to the mail.
Luke