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

Benoît Minisini g4mba5 at gmail.com
Fri Dec 6 21:26:16 CET 2019


Le 06/12/2019 à 17:38, T Lee Davidson a écrit :
> Clearing a string variable by setting it to an empty string does work. I 
> don't see where you tried to clear it. What I see is that you reload it 
> from the file every time your loop executes.
> 
> There is no method to clear attachments of an SmtpClient. It is not even 
> possible to set the Count to zero since that is a read-only property.
> 
> What you will need to do is kill and re-create the SmtpClient object in 
> each loop iteration. Specifically, do not create a New object outside of 
> the loop. For example, try something like this:
> 
>    Dim Email As SmtpClient
> 
>    While iamawake = True
> 
>      Email = New SmtpClient
>      ' Set properties
>      Email.Send
>      Email = Null
> 
>    Wend
> 
> 
> ___
> Lee
> 

Hi,

I have just updated SmtpClient so that it can be reusable (it wasn't!), 
and added a Clear() method to clear all the attachments.

Regards,

-- 
Benoît Minisini


More information about the User mailing list