Jenda

Jenda

  • NA
  • 1
  • 0

Email with attachment NOT saved on any disk

Mar 5 2004 12:49 PM
I am generating some reports (CSV or HTML) and would like to send them by email as attachments. I thought that since there is a Mail object in .Net framework this will be easy ... well it's not. Aparently MS knew better again and made a decision that all attachments have to be read from the disk (and that the file has to be named the way you want the attachment to be named). For security, speed and concurrency reasons I definitely do not want to save the report into any file. Does anyone know of any way to force the M$ object to send an attachment that's in memory? Or have a more sane one? I even tried to force the object to change the Content-type to multipart/mixed and generate the parts myself, but failed: MyMail.Headers.Add("MIME-Version", "1.0"); MyMail.Headers.Add("Content-type", "multipart/mixed; boundary=\"----=_NextPart_000_0003_01C3FF64.B6C2AD50\""); created this in the email: MIME-Version: 1.0 Content-Type: text/plain; boundary="----=_NextPart_000_0003_01C3FF64.B6C2AD50" Once again MS knows better than myself what the heck I want. Thanks, Jenda P.S.: mail.Attachments.Add(new MailAttachment(strdir+strfilename)); ??? What the fsck? Someone's suffering a heavy object overdose here? mail.Attachments.Add(strdir+strfilename); or even mail.Attach(strdir+strfilename); would be too straightforward, right?