@SocketEvent(socketId = "changevmTemplate")
  public void updatePreviewMail(VmEmailTemplateData vmData) {

    final StringWriter body = new StringWriter();
    currentBodyRenderTemplate.setTemplateScript(vmData.getBody());
    velocityTemplateRenderer.render(currentBodyRenderTemplate, currentEmailContext, body);
    html.setContent(body.toString());
  }
  @SocketEvent(socketId = "mail")
  public void displaySearchresult(MailInternalData mailData) {

    FlexibleSearchQuery query =
        new FlexibleSearchQuery(
            "Select {pk} from {EmailPage} where {uid}='" + mailData.getUid() + "'");
    SearchResult<EmailPageModel> searhResult = flexibleSearchService.search(query);
    final EmailPageModel emailPageModel = searhResult.getResult().get(0);

    FlexibleSearchQuery querybm =
        new FlexibleSearchQuery(
            "Select {pk} from {BusinessProcess } where {code}='"
                + mailData.getBusinessOrderCode()
                + "'");
    SearchResult<BusinessProcessModel> searhResultBs = flexibleSearchService.search(querybm);
    final BusinessProcessModel businessProcessModel = searhResultBs.getResult().get(0);

    final EmailPageTemplateModel emailPageTemplateModel =
        (EmailPageTemplateModel) emailPageModel.getMasterTemplate();
    currentBodyRenderTemplate = emailPageTemplateModel.getHtmlTemplate();
    currentEmailContext =
        this.executeInContext(
            new ImpersonationService.Executor<
                AbstractEmailContext<BusinessProcessModel>, RuntimeException>() {
              @Override
              public AbstractEmailContext<BusinessProcessModel> execute() throws RuntimeException {
                return emailContextFactory.create(
                    businessProcessModel, emailPageModel, currentBodyRenderTemplate);
              }
            });

    final StringWriter body = new StringWriter();
    rendererService.render(currentBodyRenderTemplate, currentEmailContext, body);
    html.setContent(body.toString());
    // label.setValue(emailPageTemplateModel.getHtmlTerendererServicemplate().getTemplateScript());
    VmEmailTemplateData vmData = new VmEmailTemplateData();
    vmData.setBody(emailPageTemplateModel.getHtmlTemplate().getTemplateScript());
    this.sendOutput("selectVmTemplate", vmData);
  }