How to attach a pdf from a server-side script

Hi,

I need to be able to attach a PDF from within my server-side script. I have the following already written

 

Mstm.SaveAttachment( new ProcessContext().FolderId,  _fileName, Convert.

 

but not sure what is required after the Convert. Should it be ToBase64String or ToBase64CharArray as I believe 64bit encoding is required? But also what follows that.

 

Help please. Thanks in advance.

 

Tagged:

Comments

  • Hi Rob

     

    You need to use Convert.ToBase64String() and pass it a byte array containing the contents of the PDF.

     

    Thanks

     

    Iain

  • Hi Iain,

     

    Please pardon my ignorance, but how do I get the contents of the pdf file into a byte array?

     

    Cheers, Rob.

  • Hi Rob

     

    Where is the PDF stored?

     

    If its on the file system you can actually use the NewAttachment method, like this:

     

    Mstm.NewAttachment(ProcessContext.FolderId, "9.0 Release Notes.pdf", @c:\temp\);

     

    If its coming from a 3rd party system (e.g. a DMS) then it depends how you are retrieving the PDF

     

    Hope that helps

     

    Iain

     

     

  • Hi Iain,

    Its on the file system so NewAttachment will do just nicely. Thanks for your help.

    Rob.