This project is read-only.

Attachment.GetStream - Obsolete?

Topics: Help requests
Nov 26, 2013 at 6:17 PM

I am developing a process that requires quick, in-memory processing of text contained in short email attachments. Writing these attachments to some temp file and then opening them up and continuing with my process is not desirable - I just want to get the text from the email and start working on it.

I am happy to have found the Attachment.GetStream() method that gives me the text, but I see that it is tagged as obsolete. Why? This is exactly what I need, and everything else I see seems to force me into saving as a file, which I absolutely do not want to do.

Is there some equivalent replacement for Attachment.GetStream that I'm just not finding? Otherwise, I would ask that some method be in place to work with attachments that does not require saving to a file. Even if it's just exposing some kind of actual Stream property to read into a MemoryStream, that would be great.

Thanks for any insight / consideration!

Nov 27, 2013 at 9:14 AM
Hi Tim,

thank you for the feedback!

The method was marked as obsolete as I found it is more practical to access the data through a byte array (Attachment.FileData). However, I can provide direct access to the string data or a MemoryStream too. I'll include this update in the coming release.


Nov 27, 2013 at 5:18 PM
Hi Pavel,

Ok, I totally missed the FileData attribute - together with ContentType, that should be all I need. Exposing a stream is always a good idea, in my opinion, so if it's not too hard and makes sense to you, I would definitely add that.

Thanks again!!!

Nov 27, 2013 at 5:29 PM
Edited Nov 27, 2013 at 10:45 PM
Hi Tim,

it is not hard to give access directly to the string data (it's in memory anyway) as well as exposing a stream. An update is coming soon.

UPDATE: I updated the code in the repository, the method GetStream is now replaced by GetTextData

Best regards,