PROKA Posted April 30, 2009 Posted April 30, 2009 Hello. I have the following 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? Quote Development & Research Department @ Elven Soft
Administrators PlausiblyDamp Posted April 30, 2009 Administrators Posted April 30, 2009 Are you getting any exceptions raised in your code? If so there is a chance the two .Dispose calls at the end of your post are not being called. You might want to move them into a Finally block e.g. Try client.Send(mail) Return True 'Succes Catch ex As Exception 'rest of error handler Finally pdf_stream.Dispose() mail.Dispose() End Try and see if that makes a difference. You may also find that creating a single instance of the SmtpClient and using for all the mail rather than creating a new one per e-mail might keep the overheads down. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.