Email with smtp a pdf

Post your Gambas programming questions here.
Post Reply
sadams54
Posts: 83
Joined: Monday 09th July 2018 3:43am

Email with smtp a pdf

Post by sadams54 » Monday 05th July 2021 11:01pm

I have a working smtp setup for my program. What does not work is when I attach a pdf file it sends but it is unreadable as it is sent as plain text. I can't find a list of mime types and most notably the mime type to set in the smtp client for sending a pdf file. Any help?

vuott
Posts: 97
Joined: Wednesday 05th April 2017 6:07pm
Location: European Union

Re: Email with smtp a pdf

Post by vuott » Tuesday 06th July 2021 12:05am

sadams54 wrote:
Monday 05th July 2021 11:01pm
... the mime type to set in the smtp client for sending a pdf file.
...maybe: :|

https://stackoverflow.com/questions/312 ... -pdf-files
https://mimeapplication.net/pdf

sadams54
Posts: 83
Joined: Monday 09th July 2018 3:43am

Re: Email with smtp a pdf

Post by sadams54 » Tuesday 06th July 2021 12:24am

application/pdf is what I already set the mime type to. Which is what your link suggests although not specifically for gambas. But I already have it as I thought it should be. I should have made it more clear. Below is the line doing the attachment.

e.Add(User.Home & "/" & StoreName & SlsID & ".pdf", "application/pdf", StoreName & SlsID & ".pdf")

it works but the mime type is not right as the file can't be opened on the other end.

User avatar
cogier
Site Admin
Posts: 756
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Email with smtp a pdf

Post by cogier » Tuesday 06th July 2021 9:34am

I had a look at this and discovered (thanks to gbWilly) that you need to load the PDF file, and then it works as expected. Try the following:-
e.Add(File.Load(User.Home &/ StoreName & SlsID & ".pdf"), "application/pdf", StoreName & SlsID & ".pdf")
Note that &/ will add a slash, if it is needed. No need for & "/" & which will add a slash if it is needed or not.

sadams54
Posts: 83
Joined: Monday 09th July 2018 3:43am

Re: Email with smtp a pdf

Post by sadams54 » Tuesday 06th July 2021 6:36pm

You are truly the god of gambas. I had a feeling it was something easy but I was looking in the wrong spot. Thank you for the help it is working perfectly now. This was for a Point of Sale that I developed and use written in gambas. Keep the great work up.

User avatar
gbWilly
Posts: 37
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: Email with smtp a pdf

Post by gbWilly » Thursday 08th July 2021 2:20pm

I had a look at this and discovered (thanks to gbWilly) that you need to load the PDF file, and then it works as expected. Try the following:-
That's a very old post of mine ;)
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer


... there is always a Catch if things go wrong!

User avatar
cogier
Site Admin
Posts: 756
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Email with smtp a pdf

Post by cogier » Friday 09th July 2021 2:01pm

That's a very old post of mine
Nice to know you are still around!

Post Reply