Develop custom process actions in SharePoint

Source: Internet
Author: User
Tags mailmessage

In the previous article, I publishedSharePointOfWorkflowEngine. You can customize the required process actions according to your requirements and insert them into the process definition file. This articleArticleDemonstrate how to develop custom process actions: Give a specifiedEmailThe address sends an email to inform you of a new report.

 

OpenVs. netCreate a "class library" project and add twoAssemblyReferences:Kaneboy. spsworkflow. dllAndMicrosoft. Sharepoint. dll.

 

Writing custom process actions is actually creatingKaneboy. spsworkflow. Actions. actionbaseAndOverrideInheritedDoaction ()Method.

 

Kaneboy. spsworkflow. Actions. actionbaseMultipleProtectedThese attributes expose some information related to this process action:

Web:CurrentSPSSite

List:The document library of the current file

User:User who executes this action

File:Current File

Listitem:List items related to the current file

Parameter:The parameter value passed in from the process definition file. For example, the definition of this action in the process definition file is<Action NS = "Tencent" prefix = "ST1" assembly = "" C:/spsworkflowactionsample. dll "type =" spsworkflowactionsample. sendemail "parameter =" kaneboy@kaneboy.com "/>", ThenParameterThe property value isKaneboy@kaneboy.com"

 

Create the workflow class now:

Public class sendemail: kaneboy. spsworkflow. Actions. actionbase

 

Then rewriteDoaction ()Method:

Public override Microsoft. Sharepoint. spfile doaction ()

{

Mailmessage mailmsg = new mailmessage ();

//The mail sending mailbox is the current user'sEmail, ThisEmailYesSPSSite user's mailbox

Mailmsg. From = This. User. Email;

//The email receiving box is obtained from the action parameters.

Mailmsg. To = This. parameter;

//The subject and body of the email are obtained from the current user and the current file.

Mailmsg. Subject = This. User. Name +"A new report was submitted:"+ This. file. Name;

Mailmsg. Body = mailmsg. subject;

 

Try

{

//This example assumes that you can useCdosysSend email

Smtpmail. smtpserver = "127.0.0.1 ";

Smtpmail. Send (mailmsg );

}

Finally

{

}

 

//ReturnsNullYou can.

Return NULL;

}

 

Compile To GetDLLFile, and thenDLLFile placementSPSA location of the server. See this process definition file. If we want to automatically send an email to the manager after the report is moved to the department manager report library

 

<Action Assembly = "" Roman ?? New? Times MSO-Hansi-font-family: Roman ?; MSO-ascii-font-family:; font-family: parameter ="

<Action Assembly = "" type = "kaneboy. spsworkflow. Actions. Move" parameter ="Department Manager Report Library"/>

 

Add a row after:

 

<Action Assembly = "C:/spsworkflowaction

<Action Assembly = "C:/spsworkflowactionsample. dll" type = "spsworkflowactionsample. sendemail" parameter = "receiver@mail.com"/>

 

AssemblyThe property value is compiled.DLLAbsolute path of the file,TypeThe attribute value is the name of the category class,ParameterThe attribute value is the recipient's mailbox.

Click here to download the complete project source code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.