2015-09-15 220 views
1

我已經將我的流星更新爲1.2,現在我正嘗試使用電子郵件附件功能,但不知道如何。流星電子郵件附件

流星指南說,是指this,但它不是非常有幫助..

if(true == true){ 
     var dataAttachments = attachment; 
     var dataText = 
     "Client Name: " + name + 
     "\rEmail: " + email + 
     "\rPhone: " + phone + 
     "\rCompany: " + company + 
     "\rDeliverables: " + deliverables + 
     "\rCopywriting: " + copywriting + 
     "\rPrint Services: " + print + 
     "\rIllustration: " + illustration + 
     "\rphotography: " + photography + 
     "\rTimelines: " + timelines + 
     "\rBudget: " + budget + 
     "\rDescription: " + description; 

     Meteor.call('sendEmail', dataText, dataAttachment); 
     //throwAlert is my helper method which creates popup with message 
     alert('Email sent'); 
    }else{ 
     alert('An error occurred. Sorry'); 
     return false; 
    } 
    } 
}); 

Meteor.methods({ 
    sendEmail: function (text) { 
    check([text], [String]); 

    this.unblock(); 

    Email.send({ 
     to: '[email protected]', 
     from: '[email protected]', 
     subject: 'New message from contact form', 
     text: text 
    }); 

    Email.send().addAttachment(attachment); 
    } 
}); 
+0

你究竟試過了什麼,以什麼方式不起作用? –

回答

1

我會建議在安裝此軟件包:https://atmospherejs.com/ashutosh/email-att 然後做:

var attachments = []; 
attachments.push({filename: "xxx", filePath: "xxx"}); 
var email = { 
    from: "[email protected]", 
    to:  "[email protected]", 
    subject: "Test!", 
    text: "Text!" 
    attachmentOptions: attachments 
}; 
Meteor.call('send_one_email_with_attachments', email, function(){}); 


Meteor.methods({ 
    send_one_email_with_attachments: function(email){ 
     this.unblock(); 
     EmailAtt.send(email); 
    }; 
}); 

在我與Meteor的內置電子郵件進行了一段時間的戰鬥之後,這讓我的生活變得更加輕鬆。它甚至可以並排工作,因此您仍然可以使用舊的非附件電子郵件功能!

+0

你把什麼放在xxx文件名中:「xxx」? –

+0

和filepath:「xxx」? –

+0

我相信你可以使用任何你想要的'filename',記住給它正確的擴展名。我爲'filePath'使用了一個外部URL;您也可以在服務器上指定一個文件。 –