Hello. I have the following code:
Problem is RAM is loading up, and if i have 3000 emails to send, eventually it will crash. Any ideeas on how to clear data from memory?
Code:
Dim mail As New MailMessage(email_from, email_address, Subject, body)
If EmailBCC <> "" Then mail.Bcc.Add(EmailBCC)
Dim client As New SmtpClient(email_smtp)
client.UseDefaultCredentials = False
client.Credentials = New Net.NetworkCredential(email_user, email_pass)
client.DeliveryMethod = SmtpDeliveryMethod.Network
mail.IsBodyHtml = True
If CuAtasament = True Then
mail.Attachments.Add(New Attachment(pdf_stream, "Factura " & NrFactura & " - " & Utilizator & ".pdf"))
End If
Dim dac As New DataAccess
Try
client.Send(mail)
Call pdf_stream.Dispose()
Call mail.Dispose()
Return True 'Succes
Catch ex As Exception
Problem is RAM is loading up, and if i have 3000 emails to send, eventually it will crash. Any ideeas on how to clear data from memory?