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.