MemoryStream - Cannot access a closed Stream
One simple approach is to get the byte array out of the closed MemoryStream and create another one:
pdf.CreatePDF(ms)
ms = new MemoryStream(ms.ToArray())
Dim email As New EmailService
email.Send(ms)
Note that it's fine to call MemoryStream.ToArray
on a closed / disposed instance of MemoryStream
. It's even documented:
Note
This method works when the MemoryStream is closed.