2012-03-07 43 views
1

經批准或拒絕我執行該是這樣的定製電子郵件通知:獲取從工作流程項,評審電子郵件通知

public void Process(WorkflowPipelineArgs args) 
    {   
     Assert.ArgumentNotNull(args, "args"); 
     ProcessorItem processorItem = args.ProcessorItem; 
     if (processorItem != null) 
     { 
      //all variables get initialized 
      var site = Sitecore.Configuration.Factory.GetSite("website"); 
      string contentPath = args.DataItem.Paths.ContentPath;    
      var contentItem = args.DataItem; 
      var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem); 
      var contentHistory = contentWorkflow.GetHistory(contentItem); 
      var status = "Approved"; 

      //Get the item from the master database 
      var workflowItem = Sitecore.Context.ContentDatabase.Items[args.DataItem.ID]; 

      //Get the workflow history so that we can email the last person in that chain. 
      if (contentHistory.Length > 0) 
      { 
       //submitting user (string) 
       string lastUser = contentHistory[contentHistory.Length - 1].User; 
       //sitecore user (so we can get email address) 
       var submittingUser = Sitecore.Security.Accounts.User.FromName(lastUser, false); 
       //approve/reject comments 
       var comments = args.Comments; 

       StringBuilder messageBody = new StringBuilder(); 

       messageBody.AppendFormat("<div style='font-weight:bold'>Domain: {0}</div>", site.HostName); 
       messageBody.AppendLine(); 
       messageBody.AppendFormat("<div style='font-weight:bold'>Content Item: {0}</div>", contentItem.Paths.FullPath); 
       messageBody.AppendLine(); 
       messageBody.AppendFormat("<div style='font-weight:bold'>Status: {0}</div>", status); 
       messageBody.AppendLine();     
       messageBody.AppendFormat("<div style='font-weight:bold'>Approver Comments: {0}</div>", comments);      

       MailMessage msg = new MailMessage(FromAddress, submittingUser.Profile.Email); 
       msg.Subject = string.Format("{0} - Content item has been approved", site.HostName); 
       msg.Body = messageBody.ToString(); 
       SmtpClient smtpClient = new SmtpClient(MailServer); 
       smtpClient.Send(msg); 
      } 
     } 
    } 

問題:我目前能得到的審閱意見,但我無法弄清楚如何獲取評論者的姓名或電子郵件。

任何想法?

感謝, Ç

回答

3

Sitecore.Context.User應該給你訪問到誰點擊的按鈕,這似乎是你在找什麼用戶。

+0

正是我在尋找的感謝! var reviewerEmail = Sitecore.Context.User.Profile.Email; var reviewerName = Sitecore.Context.User.Profile.Name; – foxtrotZulu 2012-03-07 21:49:46