2017-02-12 41 views
1

好吧,我更新了我的代码,现在它看起来像这样如何通过一个变量在一封电子邮件,流星

import { meteorhacksssr } from 'meteor/meteorhacks:ssr'; 

SSR.compileTemplate('InviteEmail', Assets.getText('InviteEmail.html')); 
var emailData = { 
    name: "tom" 
}; 


Meteor.methods({ 
    addInvite(code) { 
      Invites.insert({ 
      code : code, 
      sentTo: '[email protected]', 
      accepted: false 
     }); 

     var emailData = { 
      code: code 
}; 

    Email.send({ 
     to: "[email protected]", 
     from: "[email protected]", 
     subject: "Example Email", 
     text: SSR.render('InviteEmail', emailData), 
}); 
    } 
}); 

这里是名为InviteEmail.html

<template name="InviteEmail"> 
    <html> 
     <body> 
      hi {{code}} 
     </body> 
</html> 
</template> 
服务器文件夹,我的HTML模板

但现在我的应用程序崩溃CMD说:Error: Unknown asset: InviteEmail.html 我安装的包,现在进口它,我必须解决它

感谢每一个帮助;)

+0

@Sean也许你可以帮我 – Michael

+0

@Zim也许你可以帮我 – Michael

回答

1

为了处理转换模板成原始的HTML服务器上的过程中,我们需要一个包添加到使用meteor add meteorhacks:ssr

传递的任何数据来代替使用车把助手就像我们的应用程序调用meteorhacks:ssr 安装{{名}} 让email.html是

<html><body>hii {{name}}</body></html> 

和我们的电子邮件的代码应该是这样的

SSR.compileTemplate('htmlEmail', Assets.getText('email.html')); 

var emailData = { 
    name: "tom" 
}; 

Email.send({ 
    to: "[email protected]", 
    from: "[email protected]", 
    subject: "Example Email", 
    html: SSR.render('htmlEmail', emailData), 
}); 

更多信息阅读本https://themeteorchef.com/tutorials/using-the-email-package

,你也可以使用替代的javascript功能,该

+0

啊我明白我会尝试感谢;) – Michael

+0

我得到整个时间错误“未知资产”我能做什么;( – Michael

+0

@Zim也许你可以帮助我;( – Michael

相关问题