내 응용 프로그램에서 메일 발송과 관련하여이 비정상적인 문제가 있습니다. 처음에는 작동하지 않았습니다. (오류를 잘못 전달할 수 없게되었습니다.) 어쨌든 적절한 인증을 추가하고 작동합니다. 내 문제는 지금 약 300 개의 전자 메일 (각각 500k 첨부 파일 첨부)을 보내려고하면 응용 프로그램이 프로세스를 통해 95 % 정도 걸려 들기 시작한다는 것입니다. 여기 System.Net.Mail의 성능 문제
는 각 메일이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
내가 생각
을 보내도록 요구하는 내 코드의 일부는, 그냥 다음 하나의 SMTP conenction을 열고 바로 모든 메일을 준비하고 컬렉션에 추가 할 수있다 이처럼 전화를 걸고 컬렉션을 반복하십시오.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
이 문제가 성공적으로 해결 되었습니까? 이 일에 아직도 도움이 필요합니까? – jcolebrand