import { Imap } from '@ionic-native/imap/ngx';
constructor(private imap: Imap) { }
...
this.imap.connect({
host: 'imap.gmail.com',
user: 'my_email@gmail.com',
password: 'my-pass'
})
.then((res: Connection) => console.log(res))
.catch((error) => console.error(error));
this.imap.disconnect()
.then((res: boolean) => console.log(res))
.catch((error: any) => console.error(error));
this.imap.isConnected()
.then((res: boolean) => console.log(res))
.catch((error: any) => console.error(error));
Note: Connected to an IMAP service is REQUIRED to be able to get data from the below functions.
this.imap.listMailFolders()
.then((res: boolean) => console.log(res))
.catch((error: any) => console.error(error));
this.imap.getMessageCountByFolderName('INBOX')
.then((res: number) => {
console.log(res)
})
.catch((error: any) => {
console.error(error)
});
this.imap.searchMessagesByDatePeriod('INBOX', 1601503200000, Comparison.GE)
.then((res: number[]) => {
console.log(res)
})
.catch((error: any) => {
console.error(error)
});
this.imap.listMessagesHeadersByConsecutiveNumber('INBOX', 1200, 1280)
.then((res: Message[]) => {
console.log(res)
})
.catch((error: any) => {
console.error(error)
});
this.imap.listMessagesHeadersByDate('INBOX', 1601503200000, Comparison.GE)
.then((res: Message[]) => {
console.log(res)
})
.catch((error: any) => {
console.error(error)
});
this.imap.getFullMessageData('INBOX', 1205)
.then((res: Message) => {
console.log(res)
})
.catch((error: any) => {
console.error(error)
});
this.imap.copyToFolder('INBOX', 'Spam', [1204, 1205, 1206, 1207])
.then((res: boolean) => {
console.log(res)
})
.catch((error: any) => {
console.error(error)
});
* Sets a flag on a message
* "setFlag()" can be used for deleting messages setting the Delete flag to "FlagEnum.DELETED"
this.imap.setFlag('INBOX', [1206, 1205, 1204], FlagEnum.SEEN, true)
.then((res: ModificationResult) => {
})
.catch((error: any) => {
console.error(error)
});