//add attachments samples public static void AddAttachmentsSamples() { using (Connection K2Conn = new Connection()) { //dummy values for process instance ID and activity instance ID int processInstanceId = 1; int activityInstanceDestinationID = 10; string fileName = "Report1.pdf"; //Add an Attachment using the Connection class and the Process Instance's ID IWorkflowAttachment _attachment = K2Conn.AddAttachment(processInstanceId, fileName, GetFile("Report1.pdf")); //Add an Attachment using the Connection class and the Worklist Item's SerialNumber IWorkflowAttachment _attachment1 = K2Conn.AddAttachment("[_serialNo]", fileName, GetFile("Report1.pdf")); //Add an Attachment using the Connection class and the Process Instance's ID and Activity Instance Destination's ID IWorkflowAttachment _attachment2 = K2Conn.AddAttachment(processInstanceId, activityInstanceDestinationID, fileName, GetFile("Report1.pdf")); //Add an Attachment using the Process Instance ProcessInstance _processInstance = K2Conn.OpenProcessInstance(processInstanceId); IWorkflowAttachment _attachment3 = _processInstance.AddAttachment(fileName, GetFile("Report1.pdf")); //Add an Attachment using the WorklistItem WorklistItem _worklistItem = K2Conn.OpenWorklistItem("[_serialNo]"); IWorkflowAttachment _attachment4 = _worklistItem.AddAttachment(fileName, GetFile("Report1.pdf")); //Async exampe, where you create the attachment first and then upload the file //Add an 'empty' attachment IWorkflowAttachment _attachment5 = K2Conn.AddAttachment(processInstanceId, fileName, null); //now upload the attachment's file. //Note. You can only upload the file once and only for an 'empty' attachment. //Note. This can be used for async purposes, to create the metadata first and secondly upload the file. IAttachment attachmentWithContent = K2Conn.UploadAttachmentContent(_attachment.Id, GetFile("Report1.pdf")); } }