Email with smtp a pdf

Post your Gambas programming questions here.
Post Reply
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Email with smtp a pdf

Post by sadams54 »

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: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Email with smtp a pdf

Post by vuott »

sadams54 wrote: Monday 5th 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
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Re: Email with smtp a pdf

Post by sadams54 »

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: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Email with smtp a pdf

Post by cogier »

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.
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Re: Email with smtp a pdf

Post by sadams54 »

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: 68
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: Email with smtp a pdf

Post by gbWilly »

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: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Email with smtp a pdf

Post by cogier »

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