[Gambas-user] Using SmtpClient attachments in a loop (was User Digest, Vol 27, Issue 22)

T Lee Davidson t.lee.davidson at gmail.com
Fri Dec 6 22:41:26 CET 2019


On 12/6/19 3:26 PM, Benoît Minisini wrote:
> I have just updated SmtpClient so that it can be reusable (it wasn't!), and added a Clear() method to clear all the attachments.

I agree with Cedron. That is awesome.

And, that changes things a bit (nb. totally untested):

Dim Email As New SmtpClient
Dim sFileText as String
Dim iamawake as Boolean = True

' Set static SmtpClient properties

While iamawake = True

   sFileText = File.Load(<myfile>)
   Email.Body = sFileText
   Email.Add("text/plain", sFileText)
   Email.Send
   Email.Clear

   If iamsleeping Then iamawake = False
Wend


-- 
Lee


More information about the User mailing list