2014-11-14 70 views
0

這裏是我的解析雲代碼調用:不能獲得合併標籤的工作 - 山魈/解析

Mandrill.sendTemplate({ 
    "template_name": "start-conversation", 
    "template_content": [{ 
     "name": "example name", 
     "content": "example content" //Those are required but they are ignored 
    }], 
    "message": { 
     "to": [{ 
      "email": request.params.toUserEmail, 
      "name": request.params.toUserName 
     }], 
     "important": true, 
     "merge": true, 
     "global_merge_vars": [ 
      { 
       "rcpt": request.params.toUserEmail, 
       "vars": [ 
        { 
         "name": "TOUSERNAME", 
         "content": request.params.toUserName 
        }, 
        { 
         "name": "FROMUSERNAME", 
         "content": request.params.fromUserName 
        }, 
        { 
         "name": "TOPICNAME", 
         "content": request.params.topicName 
        }, 
        { 
         "name": "LANGUAGE", 
         "content": request.params.language 
        } 
       ] 
      } 
     ], 
    }, 

    "async": true 
},{ 
    success: function(httpResponse) { 
    console.log(httpResponse); 
    response.success("mandrillStartConvoRequest -- success -- Email sent!"); 
    }, 
    error: function(httpResponse) { 
    console.error(httpResponse); 
    response.error("mandrillStartConvoRequest -- error -- Uh oh, something went wrong"); 
    } 
}); 

這裏的<span>在我的山魈模板標籤:

<span style="line-height:20.7999992370605px"> 
*|TOUSERNAME|* 
<br><br> 
*|FROMUSERNAME|* would like to start a conversation with you about *|TOPICNAME|* in *|LANGUAGE|*  </span> 

的E-郵件發送罰款,但沒有合併=(:

enter image description here

回答

2

遠一我知道內置的Mandrill.sendTemplate方法不起作用。 所以你應該嘗試調用山魈API自己,只是做一個HTTP POST

https://parse.com/questions/send-mandrill-template-email-from-cloud-code-example-code-required

UPDATE: 什麼,我用我的項目是這樣的,請注意,我用merge_vars,但使用的是global_merge_vars

 var params = { 
      key: "xxxxxxxxxxxx", 
      template_name: "$template_name", 
      template_content: [], 
      message: { 
      to: [ 
       { 
       email: email 
       } 
      ], 
      merge_vars : [{ 
       rcpt: email, 
       vars:[ 
       { 
        "name" : "from", 
        "content" : "Test" 
       } 
       ] 
      }] 
      }, 
      async: true 
     }; 

     Parse.Cloud.httpRequest({ 
      method: "POST", 
      headers: { 
      "Content-Type": "application/json", 
      }, 
      url: "https://mandrillapp.com/api/1.0/messages/send-template.json", 
      body: params, 
      success: function(httpResponse) { 
       response.success("email sent"); 
      }, 
      error: function(httpResponse) { 
       console.error(httpResponse); 
       response.error("Uh oh, something went wrong"); 
      } 
     }); 
+0

試過了,它沒有合併。同樣的問題。 – Ramsel

+0

檢查我的更新 –

+0

其實,這工作!一定是我4分鐘前看到的延遲電子郵件。 〜感謝。 – Ramsel