Titanium - 未发送电子邮件附件

时间:2014-08-21 17:05:51

标签: email titanium appcelerator

我正在尝试从Titanium应用程序发送电子邮件并附上PDF文档,PDF文档显示在电子邮件对话框中,但在发送电子邮件时不包括在内?

这是我的代码。

var emailDialog = Ti.UI.createEmailDialog();
emailDialog.subject = "Subject";
//emailDialog.toRecipients = ['foo@yahoo.com'];
emailDialog.messageBody = 'Body';
var f = Ti.Filesystem.getFile('idata1.pdf');
emailDialog.addAttachment(f);
emailDialog.open();
} 

1 个答案:

答案 0 :(得分:0)

我发现这是让PDF通过电子邮件发送的唯一方法

var emailDialog = Ti.UI.createEmailDialog();
emailDialog.subject = "Subject";
emailDialog.messageBody = 'Body';
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "idata1.pdf");
if(file.exists()){
    emailDialog.addAttachment(file.read());
}else{
Ti.API.error('file does not exists');
}   
emailDialog.open();