简体   繁体   English

如何通过我的移动应用发送电子邮件?

[英]How to send a email from my mobile app?

I have a list of employee details in which email details are also present . 我有一份员工详细信息列表,其中还包含电子邮件详细信息。 Once I click the mail icon of one employee it should either call the email app in the mobile or open a page where I compose and send a mail. 单击某个员工的邮件图标后,它应该在移动电话上调用电子邮件应用程序,或者打开一个我撰写和发送邮件的页面。

I tried cordova plugin email composer.but I couldn't make it out 我尝试了科尔多瓦插件电子邮件作曲家。但我做不到

Can anyone help me or suggest me blogs using which I can implement. 任何人都可以帮助我或向我推荐可以实施的博客。

The code I tried is 我试过的代码是

self.sendEmail=function() {

 cordova.plugins.email.isAvailable(
function (isAvailable) {
     alert('Service is not available'); //unless isAvailable; 


cordova.plugins.email.open({
app: 'mailto',
subject: 'Sent with mailto'
})
});
}

Firstly, I can't understand why you alert always that the service is unavailable. 首先,我不明白为什么您总是会警告该服务不可用。 You have an isAvailable variable which holds if it is or it is not enabled. 您有一个isAvailable变量,该变量保存是否启用了该变量。 This line that you copied from the official link means that you should check if isAvailable is true or false. 您从官方链接复制的这一行意味着您应检查isAvailable是true还是false。 For example 例如

isAvailable ? alert('available') : alert('not available');

Then you need to have a correct email account set up in order to use the plugin. 然后,您需要设置正确的电子邮件帐户才能使用该插件。 So the device needs to be able to send emails. 因此,设备需要能够发送电子邮件。

Then you are missing the callback which can give you important details about the event and you are not using all the needed properties in a correct way. 然后,您将缺少回调函数,该回调函数可以为您提供有关事件的重要详细信息,并且您没有以正确的方式使用所有必需的属性。

cordova.plugins.email.open({
    to:          Array, // email addresses for TO field
    cc:          Array, // email addresses for CC field
    bcc:         Array, // email addresses for BCC field
    attachments: Array, // file paths or base64 data streams
    subject:    String, // subject of the email
    body:       String, // email body (for HTML, set isHtml to true)
    isHtml:    Boolean, // indicats if the body is HTML or plain text
}, callback, scope);

So your code should look in this way: 因此,您的代码应采用以下方式:

cordova.plugins.email.open({
to: ['receiver address or multiple elements for more'],
subject: 'Sent with mailto',
body: 'body of the email!'
}, function(data) { alert('callback'); alert(data);}, this);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM