Page 1 of 1

Email attachments

Posted: Saturday 15th May 2021 8:52am
by cogier
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

Re: Email attachments

Posted: Saturday 15th May 2021 11:07am
by PJBlack
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

Re: Email attachments

Posted: Saturday 15th May 2021 11:25am
by cogier
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.

Re: Email attachments

Posted: Saturday 15th May 2021 12:07pm
by PJBlack
did you tried:
Email.Add(File.Load("/tmp/Booking.csv"),"text/comma-separated-values",File.Name("/tmp/Booking.csv"))

Re: Email attachments

Posted: Sunday 16th May 2021 12:30pm
by cogier
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.