I need to send PDF file as attachment through email. I am able to send it using pub.cleant:SMTP service. However when I try to open that PDF file it gives error file is not decoded properly. I am passing htmlmailStream as input to the pub.cleant:SMTP. htmlmailStream is obtained from the output of pub.mime:getEnvelopeStream.
What is the content-type you are specifying in the smtp service under data/ or attachments and make sure it is application/PDF and also try with base64 encode/decode as Senthill suggested above.
While sending, I will encode it. I am not clear about decoding. Once I received this pdf in email after that I do not want any thing to do. It should open as expected. This is our requirement. Can you please make me more clear on when should I decode the content.
Still, I am getting the same error. Below is the flow of my code.
I invoked pub.mime:getEnvelopeStream service. It’s output is a stream.
Converted this stream into bytes.
encoded bytes into base64 using service pub.string:base64Encode. It’s output is a string.
Here I am invoking service pub.client:smtp. In attachements\conten, I passed this encoded string, contentType set to application/pdf, file name set to test.pdf and encoding set to base64.
Could you please let me know where I should try to decode it. I tried to decode it using 2-3 scenarios but still getting the same error.