Com*_*ode 5 ionic-framework ionic-view
所以我一直在尝试用 ionic 发送电子邮件。我尝试了很多教程,示例,但除了这个之外没有任何效果:https : //www.thepolyglotdeveloper.com/2014/08/send-email-android-ios-ionicframework/。
我要把这个教程放在这里。请参阅下面的答案。
cordova plugin add https://github.com/jcjee/email-composer.git
,存储库链接ionic build android
现在准备你的 AngularJS 控制器:
angular.module('myApp').controller('WhatToDoController', function ($scope, $state) {
var whatToDo = this;
/**
* Sends an email using Email composer with attachments plugin and using
* parameter email.
*
* @param email
*/
whatToDo.sendEmail = function (email) {
if (window.plugins && window.plugins.emailComposer) { //check if plugin exists
window.plugins.emailComposer.showEmailComposerWithCallback(function (result) {
//console.log("Email sent successfully");
},
null, // Subject
null, // Body
[email], // To (Email to send)
null, // CC
null, // BCC
false, // isHTML
null, // Attachments
null); // Attachment Data
}
}
});
Run Code Online (Sandbox Code Playgroud)现在在您的 html 视图中您可以使用该方法sendEmail(email)
:
<p>
Send an email to <a href="#" ng-click="whatToDo.sendEmail('example@email.com')">example@email.com</a>
</p>
Run Code Online (Sandbox Code Playgroud)
尝试在实际的智能手机上使用它,因为在模拟器中,如果您没有配置电子邮件应用程序,它将无法正常工作。
如果您遇到困难或尝试:https://www.youtube.com/watch?v = kFfNTdJXVok 或https://blog.nraboy.com/2014/08/send-email-android-ios-ionicframework
归档时间: |
|
查看次数: |
17989 次 |
最近记录: |