Guest User

Untitled

a guest
Aug 2nd, 2018
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // TODO: SEND MAIL
  2. void _sendMail() async {
  3. if (!_formKey.currentState.validate()) {
  4. return;
  5. } else {
  6. _formKey.currentState.save();
  7.  
  8. var _options = new GmailSmtpOptions()
  9. ..username = “mymailaddress@gmail.com"
  10. ..password = “myPassword”;
  11.  
  12. var _emailTransport = new SmtpTransport(_options);
  13. var _envelope = new Envelope()
  14. ..from = "mymailaddress@gmail.com"
  15. ..recipients.add(_receiverMailAddress)
  16. ..subject = "${_userDekontDetails[0][0].toString()} - Receipt”
  17. ..attachments.add(await new Attachment(file: await new File('$newDekontImage')))
  18. ..text = "${_userDekontDetails[0][0].toString()} - Receipt"
  19. ..html = '<h3>${_userDekontDetails[0][0].toString()} Receipt.</h3>'
  20. '<p>Hi, registered under my name, I am sending the receipt (${widget._currentUserReceiptNo}) with attached to this mail.</p>'
  21. '<p></p>'
  22. '<h5>Regards, </br></h5>'
  23. '${_userDekontDetails[0][0].toString()}';
  24.  
  25. _emailTransport.send(_envelope)
  26. ..then((envelope) => print('Email sent'))
  27. ..catchError((e) => print('Error occured: $e'));
  28. }
  29. }
Add Comment
Please, Sign In to add comment