[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 17:38:44 CET 2019
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
On 12/6/19 9:35 AM, Ivan Williams via User wrote:
> This is a addendum to my email yesterday - if you are using the mail function inside of a procedure with a loop - put the
> email.to.add outside of the loop else it will stack on the emails and you will receive multiple copies of the same email.
>
> Also, ftext = File.load("/media/ShortBox/Stats/pmail.txt") does not unload the previous file so it is adding all the files to
> the email as the program executes (luckily it only executes every 30 minutes) - I am currently looking for a way to unload
> the ftext once it has been loaded. ftext="" does not work and file.unload does not exist.
>
> If anyone knows the code/command to unload a file can you let me know.
>
> Thank You
>
> Ivan
>
More information about the User
mailing list