2012-08-22 96 views
1

我是新來的Alfresco(第4版),我想(實際上lib.js)創建webscript用於發送具有功能與以下簽名的電子郵件:如何發送電子郵件在露天4

function sendMail(to, subject, templatePath, templateArgs) 

這函數會在滿足一些條件時從其他web腳本中調用。我發現這樣的腳本:

var mail = actions.create("mail"); 
mail.parameters.to = "[email protected]"; 
mail.parameters.subject = "Test subject"; 
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl"); 

var templateArgs = new Array(); 
templateArgs['workflowTitle'] = "workflowTitle"; 
templateArgs['workflowPooled'] = true; 
templateArgs['workflowDescription'] = "workflowDesc"; 
templateArgs['workflowId'] = "workflowId"; 

var templateModel = new Array(); 
templateModel['args'] = templateArgs; 
mail.parameters.template_model = templateModel; 

mail.execute(search.findNode("workspace://SpacesStore/9e15aaac-b30b-4266-984f-21fe273a6113")); 

,但我不知道如何把它在我的代碼,因爲我不知道三兩件事:

  • 我可以在使用此代碼我的場景,即使js lib可以導入並用於發送各種電子郵件?

  • 如果可以,我在哪裏可以找到對動作的引用(在文件開始時導入什麼內容)?

  • 我應該把什麼作爲mail.execute函數的參數?

回答

2

mail.execute是「違規」規則。這意味着代碼會要求您在室外對節點執行該功能。因此,當您在上傳文檔時發送電子郵件時,mail.execute會使用剛創建的節點,因此您可以在郵件中追加到新創建文件的鏈接。

無論如何,您可以簡化它,並創建一個規則,當它創建/更新時觸發某些內容,並將sendmailaction.js作爲您在上面發佈的內容,自動發送給您想要的用戶。

否則,您可以創建這樣的事情:

function sendMail() 
{ 
    var mail = actions.create("mail"); 
    mail.parameters.to = bpm_groupAssignees.properties["cm:email"]; 
    mail.parameters.subject = "New File uplodaded with name " + document.name; 
    mail.parameters.from = initiator.properties["cm:email"]; 
    mail.parameters.text = "Kindly approve the document: " + document.name; 
    mail.execute(document); 
} 
sendMail();