My client can upload Pdf's in the media library. Ofcourse this is saved as a Blob on disk and the name on disk is encoded in for example blob/jkfj2kl39erkjweklfjdklf/dfkjsdfkljsdfkldfj83.pdf
Now we have a functionality that the pdf's can be emailed using a form on a page. Now i can fetch this blob programmatically as so and attach this to an email.
List attachments = new List();
ContentReference cr = new ContentReference(mediaID);
var media = contentLoader.Get(cr);
if (media != null)
string filePath = string.Empty;
var fileBlob = media.BinaryData as FileBlob;
if (fileBlob != null)
filePath = fileBlob.FilePath;
However the pdf name is not nice and descriptive if you receive such a pdf. Are there alternatives on how i can sent the pdf in a more descriptive manner?
attachments.Add(new Attachment(fileBlob.OpenRead(), media.Name));
Arghh.. forgot to check the overloads... thanks Dejan.. once again to the rescue..