Ios Mailgun:使用解析云代码发送图像

Ios Mailgun:使用解析云代码发送图像,ios,parse-platform,mailgun,Ios,Parse Platform,Mailgun,我有一个代码定义为 Parse.Cloud.define("mailgunSendMail", function(request, response) { var Mailgun = require('mailgun'); Mailgun.initialize('photoshare.com', 'APPKey'); Mailgun.sendEmail({

我有一个代码定义为

Parse.Cloud.define("mailgunSendMail", function(request, response) {

               var Mailgun = require('mailgun');
               Mailgun.initialize('photoshare.com', 'APPKey');

               Mailgun.sendEmail({
                                 to: "toTestUser@mail.com",
                                 from: "fromTestUser@mail.com",
                                 subject: "Hello from Cloud Code!",
                                 text: "Using Parse and Mailgun is great!",
                                 attachment:"ZXhhbXBsZSBmaWxl"
                                 }, {
                                 success: function(httpResponse) {
                                 console.log(httpResponse);
                                 response.success("Email sent!");
                                 },
                                 error: function(httpResponse) {
                                 console.error(httpResponse);
                                 response.error("Uh oh, something went wrong");
                                 }
                                 });
               });

邮件已成功发送,收件人已收到邮件,但缺少附件。如何以数据的形式发送附件?

根据parse,目前无法通过电子邮件发送附件

但是,如果您可以像这样在HTML代码中包含图像文件,那么这符合您的需要

html: '<html><body style="text-align:center;"><img border="0" src="http://files.parse.com/6ffa6b80-d0eb-401f-b663-22d4a16df004/bfed9ac4-058c-41fc-a0f1-fb6155572c12-ad77a082-453f-42f7-94ef-40c3f3e885e6.png" alt="Pulpit rock" width="300" height="150"></body></html>'
html:'

苏巴什的答案是正确的。我刚刚编辑了我的问题:

Parse.Cloud.define("mailgunSendMail", function(request, response) {
           var Mailgun = require('mailgun');
           Mailgun.initialize('photoshare.com', 'AppKey');

           Mailgun.sendEmail({
                             to: "toTestuser@mail.com",
                             from: "fromTestUser@mail.com",
                             subject: "Hello from Cloud Code!",
                             text: "Using Parse and Mailgun is great!",
                             html: '<html><body><img src="' + request.params.imageUrlKey + '"></body></html>'                                 }, {
                             success: function(httpResponse) {
                             console.log(httpResponse);
                             response.success("Email sent!");
                             },
                             error: function(httpResponse) {
                             console.error(httpResponse);
                             response.error("Uh oh, something went wrong");
                             }
                             });
           });
Parse.Cloud.define(“mailgunSendMail”),函数(请求、响应){
var Mailgun=require('Mailgun');
Mailgun.initialize('photoshare.com','AppKey');
Mailgun.sendmail({
至:toTestuser@mail.com",
来自:fromTestUser@mail.com",
主题:“你好,来自云代码!”,
文本:“使用Parse和Mailgun很棒!”,
html:'}{
成功:函数(httpResponse){
console.log(httpResponse);
回复。成功(“发送电子邮件!”);
},
错误:函数(httpResponse){
控制台错误(httpResponse);
错误(“哦,出了点问题”);
}
});
});

其中,
imageUrlKey
是一个包含图像url的参数键。

如何将从请求参数获取的图像url插入此html字符串?您可以这样做:“”