J'ai ce problème inhabituel avec mailing de mon application. Au début, ça ne fonctionnait pas (être incapable de relayer les erreurs de la merde) de toute façon j'ai ajouté l'authentification correcte et ça marche. Mon problème est maintenant, si j'essaie d'envoyer environ 300 emails (chacun avec une pièce jointe de 500k) l'application commence à traîner environ 95% à travers le processus.Problème de performance avec System.Net.Mail
Voici une partie de mon code qui est appelé pour chaque courrier à envoyer
Using mail As New MailMessage()
With mail
.From = New MailAddress(My.Resources.EmailFrom)
For Each contact As Contact In Contacts
.To.Add(contact.Email)
Next
.Subject = "Accounting"
.Body = My.Resources.EmailBody
'Back the stream up to the beginning orelse the attachment
'will be sent as a zero (0) byte file.
attachment.Seek(0, SeekOrigin.Begin)
.Attachments.Add(New Attachment(attachment, String.Concat(Item.Year, Item.AttachmentType.Extension)))
End With
Dim smtp As New SmtpClient("192.168.1.2")
With smtp
.DeliveryMethod = SmtpDeliveryMethod.Network
.UseDefaultCredentials = False
.Credentials = New NetworkCredential("username", "password")
.Send(mail)
End With
End Using
With item
.SentStatus = True
.DateSent = DateTime.Now.Date
.Save()
End With
Return
Je pensais, puis-je préparer simplement tous les mails et les ajouter à une collection puis ouvrez un conenction SMTP et juste itérer la collection, en appelant l'envoi comme celui-ci
Using mail As New MailMessage()
...
MailCollection.Add(mail)
End Using
...
Dim smtp As New SmtpClient("192.168.1.2")
With smtp
.DeliveryMethod = SmtpDeliveryMethod.Network
.UseDefaultCredentials = False
.Credentials = New NetworkCredential("username", "password")
For Each mail in MainCollection
.Send(mail)
Next
End With
Avez-vous déjà résolu ce problème avec succès? Avez-vous encore besoin d'aide pour cela? – jcolebrand