Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Instead of:
attachments.Add(new Attachment(filePath));
Try this:
attachments.Add(new Attachment(fileBlob.OpenRead(), media.Name));
Arghh.. forgot to check the overloads... thanks Dejan.. once again to the rescue..
Hi guys,
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;
attachments.Add(new Attachment(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?