我试图向很多人发送大量电子邮件,但是在一段时间内发送大量邮件后,我收到了4.4.2 Message submission rate for this client has exceeded the configured limit
消息,或者我的程序刚刚在MsgBox中以相同的消息结束。
我发现,我每100秒可以发送5封电子邮件,并添加一个计时器,等待100秒并发送接下来的5封电子邮件。.但是要花很长时间。
Dim Smtp_Server As New SmtpClient()
Dim email As New MailMessage()
Static start As Single
Static seconds As Single = 100
Try
For Each b_MailInfo As ALG.Logic.clsMailinfo In l_lsMailinfo
Dim l_sEmpfaenger() As String = b_MailInfo.DTA.Empfaenger.Value.Split(";")
For Each b_sEmpfaeger As String In l_sEmpfaenger
Dim i_iEmail As Integer = 0
'wenn's eine E-MailAdresse ist
If b_sEmpfaeger.Contains("@") Then
Smtp_Server.Credentials = New Net.NetworkCredential("Batchserver@testMail.com", "testPW")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = False
Smtp_Server.Host = "test-srv-54.testMail.com"
email = New MailMessage()
email.From = New MailAddress("batchserver@testMail.com")
email.To.Add(b_sEmpfaeger)
email.Subject = b_MailInfo.DTA.Betreff.Value.ToString
email.IsBodyHtml = True
email.Body = b_MailInfo.DTA.Text.Value.ToString
Smtp_Server.Send(email)
i_iEmail += 1
If i_iEmail > 4 Then
start = VB.Timer()
Do While VB.Timer() < start + seconds
System.Windows.Forms.Application.DoEvents()
Loop
i_iEmail = 0
End If
Else
Dim UsersInGroup As New Collection()
Dim de As New DirectoryEntry("LDAP://testMail.com")
Dim MemberSearcher As New DirectorySearcher
With MemberSearcher
.SearchRoot = de
.Filter = "(&(ObjectClass=Group)(CN=" & b_MailInfo.DTA.Empfaenger.Value.ToString & "))"
.PropertiesToLoad.Add("Member")
End With
Dim mySearchResults As SearchResult = MemberSearcher.FindOne()
For Each b_sUser As String In mySearchResults.Properties("Member")
Dim l_sCN As String = b_sUser.Split(",")(0)
Do While l_sCN.Contains(" ")
l_sCN = l_sCN.Replace(" ", " ")
Loop
Dim l_sUser() As String = l_sCN.Split("=")(1).Split(" ")
Select Case l_sUser.Length
'kein User
Case 1
Smtp_Server.Credentials = New Net.NetworkCredential("Batchserver@testMail.com", "testPW")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = False
Smtp_Server.Host = "test-srv-54.testMail.com"
'User
Dim b_sString As String = Join(l_sUser, ".")
email = New MailMessage()
email.From = New MailAddress("batchserver@testMail.com")
email.To.Add(b_sString & "@testMail.com")
email.Subject = b_MailInfo.DTA.Betreff.Value.ToString
email.IsBodyHtml = True
email.Body = b_MailInfo.DTA.Text.Value.ToString
Smtp_Server.Send(email)
i_iEmail += 1
If i_iEmail > 4 Then
start = VB.Timer()
Do While VB.Timer() < start + seconds
System.Windows.Forms.Application.DoEvents()
Loop
i_iEmail = 0
End If
Case 2
Smtp_Server.Credentials = New Net.NetworkCredential("Batchserver@testMail.com", "testPW")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = False
Smtp_Server.Host = "test-srv-54.testMail.com"
'UsersInGroup.Add(Join(l_sUser, "."))
email = New MailMessage()
email.From = New MailAddress("batchserver@testMail.com")
Dim b_sString As String = Join(l_sUser, ".")
email.To.Add(b_sString & "@testMail.com")
'email.To.Add("ilja.g@testMail.com")
Debug.Print(b_sString & "@testMail.com")
email.Subject = b_MailInfo.DTA.Betreff.Value.ToString
email.IsBodyHtml = True
email.Body = b_MailInfo.DTA.Text.Value.ToString
Smtp_Server.Send(email)
i_iEmail += 1
If i_iEmail > 4 Then
start = VB.Timer()
Do While VB.Timer() < start + seconds
System.Windows.Forms.Application.DoEvents()
Loop
i_iEmail = 0
End If
Case 3
Smtp_Server.Credentials = New Net.NetworkCredential("Batchserver@testMail.com", "testPW")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = False
Smtp_Server.Host = "test-srv-54.testMail.com"
email = New MailMessage()
email.From = New MailAddress("batchserver@testMail.com")
Dim b_sString As String = l_sUser(0) + "." + l_sUser(1) + l_sUser(2)
email.To.Add(b_sString & "@testMail.com")
email.Subject = b_MailInfo.DTA.Betreff.Value.ToString
email.IsBodyHtml = True
email.Body = b_MailInfo.DTA.Text.Value.ToString
Smtp_Server.Send(email)
i_iEmail += 1
If i_iEmail > 4 Then
start = VB.Timer()
Do While VB.Timer() < start + seconds
System.Windows.Forms.Application.DoEvents()
Loop
i_iEmail = 0
End If
Case Else
Debug.Fail("Länge " + l_sUser.Length.ToString)
End Select
Next b_sUser
End If
Next b_sEmpfaeger
Try
BASE.DAC.beginTransaction()
b_MailInfo.speichern() 'Verarbeitet setzen
BASE.DAC.commitTransaction()
Catch ex As Exception
BASE.DAC.rollbackTransaction()
End Try
Next
Catch ex As Exception
Smtp_Server.Credentials = New Net.NetworkCredential("Batchserver@testMail.com", "testPW")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = False
Smtp_Server.Host = "test-srv-54.atx-testMail.com"
email = New MailMessage()
email.From = New MailAddress("batchserver@testMail.com")
email.To.Add("ilja.g@testMail.com")
email.Subject = "clsALG_Mailinfo exception || Public Overrides Sub RunJob()"
email.IsBodyHtml = False
email.Body = ex.ToString
Smtp_Server.Send(email)
End Try
那我的代码做什么。
我有4种不同的可能性。首先,我只能收到一两个电子邮件-首先我将其拆分并发送。
其他人,我有一个组和名称。.首先,从活动目录获取名称后,我需要“制作”电子邮件地址。然后,我将电子邮件发送到“制造商”地址。
在上一个中,我只是将异常错误发送给我。
是否有任何解决方案可以从服务器获取提交率或仅将其发送到服务器,以便他可以在发送电子邮件时自行处理?