Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream
Email with attachment from MemoryStream Email with attachment from MemoryStream
Email with attachment from MemoryStream
Go Back  Xtreme Visual Basic Talk > > > Email with attachment from MemoryStream


Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2011, 12:06 PM
phrosty's Avatar
phrosty phrosty is offline
Regular
 
Join Date: Oct 2005
Location: NC
Posts: 58
Question Email with attachment from MemoryStream


I'm attempting to create a MemoryStream object from an existing PDF file in a database and then attach it to an email. The email sends fine, but the received file is only 256 B in size. Here's my code:

Code:
  Dim frm As ParkReservationsDAL.Reservations.Reservation_FormsRow = (New FormsBLL).GetFormByID(formID)(0)
                    'Dim fn As String = Server.MapPath("\ParkReservations\Temp\" + Replace(frm.Filename, " ", "_") + rnd.ToString + ".pdf")
                    'Dim fs As New System.IO.FileStream(fn, IO.FileMode.Create)
                    Dim ms As New System.IO.MemoryStream
                    ms.Write(frm.Document, 0, frm.Document.Length)

                    msArr.Add(ms)
(I iterate through the arraylist msArr when adding multiple attachments)

Attaching to email:

Code:
 For Each ms As System.IO.MemoryStream In attachments
                    Dim att As New System.Net.Mail.Attachment(ms, "test.pdf", System.Net.Mime.MediaTypeNames.Application.Pdf)
                    mMailMessage.Attachments.Add(att)
                Next

                ' Send the mail message
                mSmtpClient.Send(mMailMessage)
I've even seen samples such as these online and followed them to the letter, but just can't get it to work.

Is there a setting I overlooked? Could it be a setting on the email server itself? The attachments work properly if I use a file on disk, but I don't have that option b/c we want to avoid setting up extra permissions or adding impersonation code if possible.

Thanks!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream Email with attachment from MemoryStream
Email with attachment from MemoryStream
Email with attachment from MemoryStream
 
Email with attachment from MemoryStream
Email with attachment from MemoryStream
 
-->