Email attachments

Post your Gambas programming questions here.
Post Reply
User avatar
cogier
Site Admin
Posts: 721
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Email attachments

Post by cogier » Saturday 15th May 2021 8:52am

Does anybody know how to add an attachment to Gambas email?

The command
Dim Email As New SmtpClient

Email.Add(What do I put here?)

Email.Add

User avatar
PJBlack
Posts: 141
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: Email attachments

Post by PJBlack » Saturday 15th May 2021 11:07am

Methode
Add ( Data As String [ , MimeType As String, Name As String ] )

Description
Adds an email attachment. Data is the data that usually comes directly from the file you want to attach. MimeType is the MIME type of the attached data. By default it is 'text/plain'. Name is the name of the attachment. It is automatically generated if not specified. Currently not all MIME types are supported.

Beschreibung
Fügt einen EMail-Anhang hinzu. Data sind die Daten, die in der Regel direkt aus der Datei kommen, die Sie anhängen möchten. MimeType ist der MIME-Typ der angehängten Daten. Standardmäßig ist es 'text/plain'. Name ist der Name des Anhangs. Er wird automatisch generiert, wenn er nicht angegeben wurde. Gegenwärtig werden nicht alle MIME-Typen unterstützt.

copy/paste from gambas-buch 24.4.0.2

EDIT

I#ve seen that hans just translated the wiki text ... sorry

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

Re: Email attachments

Post by cogier » Saturday 15th May 2021 11:25am

Thanks PJBlack but I have seen that information.

I have tried: -
Email.Add("/tmp/Booking.csv", "text/csv")
and
Email.Add(sNew.Join(gb.NewLine), "text/csv", "Booking.csv")
but neither work for me, the email is sent but not with any attachment.

User avatar
PJBlack
Posts: 141
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: Email attachments

Post by PJBlack » Saturday 15th May 2021 12:07pm

did you tried:
Email.Add(File.Load("/tmp/Booking.csv"),"text/comma-separated-values",File.Name("/tmp/Booking.csv"))

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

Re: Email attachments

Post by cogier » Sunday 16th May 2021 12:30pm

OK I have sorted this. My tip is don't set SmtpClient.Alternative value to True.

The mime text/csv now works fine.

Thanks for the input.

Post Reply