This project is read-only.

Download Attachments

Topics: Help requests
Jan 12, 2014 at 3:55 PM
Edited Jan 12, 2014 at 3:57 PM
Can you tell me how to download attachments..

I am using .Save method but it is giving error as Object reference not set to instance of an object..

It is giving error in Attachment.cs file in method :

public void Save(string folder, string fileName = null)
        string path = Path.Combine(folder,
            string.IsNullOrEmpty(fileName) ? (string.IsNullOrEmpty(FileName) ? "unnamed.dat" : FileName) : fileName);
        using (
            var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write))
            fileStream.Write(FileData, 0, FileData.Length);    //error is on this line
Jan 12, 2014 at 3:58 PM
Have you initialized FileData?

Jan 12, 2014 at 4:33 PM
Edited Jan 12, 2014 at 4:33 PM
Hi paliwalvimal1993,

attachments are not downloaded automatically unless you set the fetch mode to do it. Before saving the attachment, call the Download method to fetch it:
I recommend you to take a deeper look at the sample application.