react-native-mailcore icon indicating copy to clipboard operation
react-native-mailcore copied to clipboard

app crashed when loggedin user trying to replay any mail for first time

Open PrantikMondal opened this issue 5 years ago • 0 comments

0

I am using react-native-mailcore library to reply mail. As per the instruction on that library doc, i am doing smtp login before calling MailCore.sendMail. From second time reply mail is working fine with same code as well as For compose mail i am using same code to send mail. It is working fine for that case also. My code is given bellow.

import MailCore from 'react-native-mailcore'; var LocalStorage = require('react-native-local-storage');

sendMail = async () => { let user = await LocalStorage.get('user'); await MailCore.loginSmtp({ hostname: 'smtp.gmail.com', port: 465, username: user.email, password: user.password, }).catch(error => ToastAndroid.show(error,ToastAndroid.LONG)) // All the values from the state are coming correctly let subject = this.state.subject || '(No Subject)'; let body = this.state.compose + this.state.body || ''; let from = { addressWithDisplayName : this.state.name, mailbox: this.state.user, } let to = {[this.state.to] : 'to labels'};

// App crashed here while called sendMail

await MailCore.sendMail({
  headers:{
    isEncrypted: 'true',
  },
  from:from,
  to:to,
  subject:subject,
  body,  
}).then(()=>{
    this.goBack(); //navigating to main page after success
    ToastAndroid.show("sending...",ToastAndroid.SHORT);
}).catch(err => ToastAndroid.show(err,ToastAndroid.LONG));

}

PrantikMondal avatar Feb 21 '20 07:02 PrantikMondal