gpt4 book ai didi

javascript - 屏幕截图未发送至钛合金电子邮件

转载 作者:行者123 更新时间:2023-11-28 09:18:31 24 4
gpt4 key购买 nike

我使用了下面的代码,它是 http://developer.appcelerator.com/question/135462/save-screenshot-temporarily-then-retrieve-when-ready 给出的已接受答案

但是当电子邮件对话框打开时,它显示一个附件,该文件是屏幕截图,但发送电子邮件后,收到的电子邮件中没有附件。这意味着屏幕截图未发送。

谁能告诉我这段代码有什么问题吗???

var win = Ti.UI.createWindow({
// backgroundColor : '#666666'
backgroundColor : 'red',
// backgroundImage : 'img/1.jpg'
});

var btn = Ti.UI.createButton({
width : 100,
height : 30,
title : 'Test'
});

btn.addEventListener('click', function(e) {
Titanium.Media.takeScreenshot(function(e) {
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'test.png');
f.write(e.media);

var emailDialog = Titanium.UI.createEmailDialog();
emailDialog.setToRecipients(['test@gmail.com']);
emailDialog.setSubject('test');
emailDialog.setMessageBody('testing......');
emailDialog.setHtml(true);
emailDialog.setBarColor('black');
emailDialog.addAttachment(f.read());

emailDialog.addEventListener('complete', function(e) {
if(e.result == emailDialog.SENT) {

alert("message was sent");

}
});
emailDialog.open();
});
});

win.add(btn);

win.open();

最佳答案

addAttachment 函数可以获取 blob,您不必将其保存到磁盘。此外,这可能不起作用,因为您可能没有对 applicationDataDirectory 的写访问权限。

只需从 e.media 传递提供的 blob,如下所示:

Titanium.Media.takeScreenshot(function(e) {
var emailDialog = Titanium.UI.createEmailDialog();
// Get the supplied blob and attach
emailDialog.addAttachment(e.media);
// ...... add other email things here
});

关于javascript - 屏幕截图未发送至钛合金电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15310182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com