Skip to main content

 


 


 


 


 


 


 


 


 


 


 


 


 


 



 



 



 


Hi guys, I am trying to attach a document from a sharepoint document library to an email event message, but all my workflow instances go to an error state :



Could not load file or assembly 'Microsoft.SharePoint.Library, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.


I have referenced the dll but I am still getting the error, please advice


Thanks in advance.


Please find the server object model code below:


can i use the client object model instead of the server object model ???



try


{



 



 



 


string siteUrl = K2.ProcessInstance.DataFieldsc"MossSiteUrl"

].Value.ToString();



 



 



 


using (SPSite site = new SPSite

(siteUrl))


{



 



 



 


using (SPWeb

web = site.OpenWeb())


{



web.AllowUnsafeUpdates =



 



 


true

;



 



 



 


//ApplicantDocuments



 



 



 


string fileName = K2.ProcessInstance.Folio.Replace("/", "_") + "incompleteinformationletter.pdf"

;



 



 



 


string url = siteUrl + "/" + "ApplicantDocuments" + "/"

+ fileName;



 



 



 


SPFile

file = web.GetFile(url);



 



 



 


//



 



 



 


byter] buffer = (byte

;])file.OpenBinary();



System.IO.



 



 


MemoryStream ms = new System.IO.MemoryStream

(buffer);



 



 



 


this.EmailMessage.Attachments.Add(new Attachment(ms, "AcknowledgementLetter.pdf"

));



web.AllowUnsafeUpdates =



 



 


false

;


 


}


}


}



 



 



 


catch (Exception

ex)



Dumasoka, this is covered with out of the box events. Using K2 Studio you can get this done real quick by doing the following:


 


- Create a new Data field and select Binary as the type


- Using the SharePoint documents event, select Download Documents > To K2 Field, specify the document location in SharePoint and store the result in data field created above


- Now in your email event, specify the data field from above as the attachment


- Done 



Hello Renier,


Thanks for the reply man...


One word for you... SUCCESS!!!!


Many thanks..


Hello Renier,

We are deploying on client site wih the suggested solution...

When configuring the Sharepoint Document event we get the following error when testing the site URL connection :

"The request has failed with HTTP status 404 : Not Found"

Please Help,

Thanks in advance

Hi Renier,


 


I found this poster, I've tried to use your recommendation but i am receiving "server was unable to process request error,  Cannot open file"...


Can you please give more details


 


Thanks


Hi Dumasoka,


 


Can you please explain how did u use this recommendation as its not working for me. i am receiving error "server was unable to process request,  Cannot open file"


 


Thanks


Reply