how to send file Attachment by Mail In Flutter

Viewed 45

hello i'm trying to send email with attachment using mailer flutter so i i specified the file path but when the email is sent i find just the text without the attachment what is wrong ? . this the code :

final equivalentMessage = Message()
  ..from = Address(username, '***** ')
  ..recipients.add(Address('********'))
  //..ccRecipients.addAll([Address('destCc1@example.com'), 'destCc2@example.com'])
  //..bccRecipients.add('bccAddress@example.com')
  ..subject = 'Test Dart Mailer library ::  :: ${DateTime.now()}'
  ..text = 'This is the plain text.\nThis is line 2 of the text part.'
  ..html =
      '<h1>Test</h1>\n<p>Hey! Here is some HTML content</p><img src="cid:myimg@3.141"/>'
  ..attachments = [
    FileAttachment(File('/path/hello.txt'))

  ]; 
0 Answers
Related