import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { EmailComposer } from '@ionic-native/email-composer';
@Component({
selector: 'page-about',
templateUrl: 'about.html'
})
export class AboutPage {
sendObj = {
to: '',
cc: '',
bcc: '',
attachments:'',
subject:'',
body:''
}
constructor(public navCtrl: NavController,private emailComposer: EmailComposer) {}
sendEmail(){
let email = {
to: this.sendObj.to,
cc: this.sendObj.cc,
bcc: this.sendObj.bcc,
attachments: [this.sendObj.attachments],
subject: this.sendObj.subject,
body: this.sendObj.body,
isHtml: true
};
this.emailComposer.open(email);
}
}
starts here html about
<ion-header>
<ion-navbar>
<ion-title>
Send Invoice
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-item>
<ion-label stacked>To</ion-label>
<ion-input [(ngModel)]="sendObj.to"></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>CC</ion-label>
<ion-input [(ngModel)]="sendObj.cc"></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>BCC</ion-label>
<ion-input [(ngModel)]="sendObj.bcc"></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>Add pdf</ion-label>
<ion-input [(ngModel)]="sendObj.attachments" type="file"></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>Subject</ion-label>
<ion-input [(ngModel)]="sendObj.subject"></ion-input>
</ion-item>
<ion-item>
<ion-label stacked>Text message</ion-label>
<ion-input [(ngModel)]="sendObj.body"></ion-input>
</ion-item>
<button ion-button full (click)="sendEmail()">Send Email</button>
</ion-content>
other stuff here
import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { File } from '@ionic-native/file';
import { FileOpener } from '@ionic-native/file-opener';
import { EmailComposer } from '@ionic-native/email-composer';
@NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
providers: [
StatusBar,
SplashScreen,
EmailComposer,
{provide: ErrorHandler, useClass: IonicErrorHandler},
File,
FileOpener
]
})
export class AppModule {}