Attachment.GetStream - Obsolete?

Topics: Help requests
Nov 26, 2013 at 5:17 PM
Hello,

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!

-Tim
Coordinator
Nov 27, 2013 at 8: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.

Greets,

Pavel
Nov 27, 2013 at 4: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!!!

-Tim
Coordinator
Nov 27, 2013 at 4:29 PM
Edited Nov 27, 2013 at 9: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,

Pavel