使用Titanium Developer Application发送电子邮件

时间:2010-12-10 10:29:52

标签: android titanium

我正在尝试创建从钛开发人员应用程序发送电子邮件的应用程序

[代码]

b.addEventListener('click', function() {
var emailDialog = Titanium.UI.createEmailDialog();
emailDialog.subject = "Hello from Titanium";
emailDialog.toRecipients = ['foo@yahoo.com'];
emailDialog.open();
   });

[/代码]

它打开弹出窗口,用于发送电子邮件。当我点击发送邮件时编写邮件。

它没有发送邮件。

请帮助

先谢谢 Pratik Asthana

1 个答案:

答案 0 :(得分:1)

从kitchenSink尝试这个...我注意到你没有使用“setSubject”或“setToRecipients”

    var emailDialog = Titanium.UI.createEmailDialog();
    emailDialog.setSubject('Hello from Titanium!');
    emailDialog.setToRecipients(['foo@yahoo.com']);
    emailDialog.setCcRecipients(['bar@yahoo.com']);
    emailDialog.setBccRecipients(['blah@yahoo.com']);

    if (Ti.Platform.name == 'iPhone OS') {
        emailDialog.setMessageBody('<b>Appcelerator Titanium Rocks!</b>å');
        emailDialog.setHtml(true);
        emailDialog.setBarColor('#336699');
    } else {
        emailDialog.setMessageBody('Appcelerator Titanium Rocks!');
    }

    // attach a blob
    emailDialog.addAttachment(event.media);

    // attach a file
    var f = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'cricket.wav');
    emailDialog.addAttachment(f);

    emailDialog.addEventListener('complete',function(e)
    {
        if (e.result == emailDialog.SENT)
        {
            if (Ti.Platform.osname != 'android') {
                // android doesn't give us useful result codes.
                // it anyway shows a toast.
                alert("message was sent");
            }
        }
        else
        {
            alert("message was not sent. result = " + e.result);
        }
    });
    emailDialog.open();