January 26, 2013

// // Leave a Comment

Send SharePoint List Attachment link in Email through Sequential Workflow




1)      Open the Visual Studio and run as Administrator



2)      File → New Project → Installed Templates → SharePoint → 2010 → Sequential Workflow

Give name and Select the Location.

3)
Select the site and click next. If you want can give Validate also.

4)
Give name of the work flow and select list work flow . Click next...

5)
Select the list to associate and click next.


6)

Specify the conditions on which the work flow should work and click Finish

7)

Workflow1.cs[Design] file opens up.
In this file drag “sendEmail” from toolbox under sharepoint below onworkflowActicated1 box.
The resulting looks like below.





8)
Right click sendEmail1 and goto properties.
Under properties Find Correlation Token and select workflowToken and OwnerActivityName to Workflow1


9)
Find the To properties for sendEmail1 and click on the … Button.

In the bind to an activity window, Select the tab Bind to a new member and Select the Create Field and Click OK



10)  Do the same step 9 to Subject and Body properties.
The resulting image will be like this after changing the Body,Subject and TO properties.



11)

Open the workflow1.cs file (Code File) and add the below code .

private void sendEmail1_MethodInvoking(object sender, EventArgs e) {

            SPListItem myListItem = workflowProperties.Item;

            string url = myListItem.Attachments.UrlPrefix + myListItem.Attachments[0];
           
                sendEmail1_To1 = "email@domain.com";

                sendEmail1_Subject1 = "Email Subject";

                sendEmail1_Body1 = "Dear All Please find the attachment link" + url ;


}




12)
Build and deploy . After successful deployment test the list where the workflow was targeted.


0 comments:

Post a Comment