매일 4 명의 첨부 파일을 5 명의 외부 수신자에게 보내는 VB.NET 프로그램이 있습니다. 매일 이러한 첨부 파일의 크기는 149KB에서 161KB 사이입니다. VB.NET 프로그램이 잘못된 전자 메일 크기 제한 오류를 생성합니다.
어떤 날
는 메시지가이 메시지와 함께 우리의 Exchange 서버에서 다시 반송됩니다 :'반환 원격 서버 (550) 5.2.3 RESOLVER.RST.SendSizeLimit.Org; 이 때문에
이 메시지는 누구에게 전달되지 않은 : 너무 메시지의 크기는 약 160 * 4 = 640킬로바이트해야
이 조직 '에 대한 큰하지만의 BounceBack 메시지가 우리에게 알려줍니다 너무 큰. 제한은 24MB입니다. 이 메시지는 35MB입니다.
확실하지 않지만 35MB 그림은 첨부 파일의 총 크기에 5 명의 수신자 모두를 곱한 것처럼 보입니다.
다른 날에 발송합니다. 실패 할 때 우리가 찾을 수있는 패턴이 없습니다. 보통 주당 5 일 중 1-3 일입니다. 또한 blat과 배치 파일을 사용하여 동일한 첨부 파일을 동일한 수신자에게 보내면 항상 올바르게 전송됩니다.
이전에이 프로그램을 다른 서버에서 실행했으나 (이 기능이 작동하지 않음)이 메시지와 함께 실패하지 않았습니다. 이메일이 보내는 방식을 방해하는 특정 서버가있는 것처럼 보이지만 어디에서 볼 것인지 잘 모릅니다. .NET 프로그램과 blat이 어떻게 든 상호 작용할 수 있습니까? 나는 오래된 서버가 낡은 것을 믿지 않는다.
저는 개인적으로 모든 교환 기록에 액세스 할 수 없지만 동료에게 확인 기록을 남겼습니다. 그들은 이상한 것을 찾을 수 없다고 말했습니다. 코드
편집 :
Public Sub SendEmail()
Dim objMail As New SmtpClient(ConfigurationManager.AppSettings("MailServer").ToString, 25)
Dim objMess As MailMessage
Dim strBody As String
Dim JHPath As String : JHPath = ConfigurationManager.AppSettings("JHFiles").ToString
Try
'create a new message object
objMess = New Net.Mail.MailMessage()
objMail.Timeout = 90000 '90 seconds
'add sender to the message object
objMess.From = New MailAddress(ConfigurationManager.AppSettings("MailFromAddr"), "<redacted>")
'add recipients
For Each addr As String In ConfigurationManager.AppSettings("MailToAddr").Split(";")
objMess.To.Add(addr)
Next
'the body text of the email
strBody = ""
'add subject to the message object
objMess.Subject = "<redacted> " & labelsDate.ToString("MM/dd/yyyy") & " - " & <redacted>
'add body to the message object
objMess.Body = strBody
Dim filAge As Integer
'attach the 4 files necessary for the <redacted> - only today's
For Each fil As String In IO.Directory.GetFiles(JHPath)
filAge = (Today() - IO.File.GetLastWriteTime(fil)).Days
If filAge < 1 And Not (fil Like "*Thumbs.db") Then 'add today's files only, in case archiving did not happen
objMess.Attachments.Add(New Attachment(fil))
End If
Next
'send the email
Console.WriteLine(Now() & " -- Sending email..... " & vbCrLf)
writer.WriteLine(Now() & vbTab & "Sending email..... " & vbCrLf)
'try sending the message
Try
objMail.Send(objMess)
writer.WriteLine(Now() & vbTab & "Email sent and cleaned up. " & vbCrLf)
Catch ex As Exception
Dim mess As String : mess = Now() & " -- Failure sending email to <redacted>!"
Console.WriteLine(mess)
writer.WriteLine(mess)
Finally
'get rid of the message object, cleanup
objMess.Dispose()
End Try
Catch ex As Exception
Console.WriteLine(Now() & " -- Other Error Emailing to <redacted>: " & ex.Message)
writer.WriteLine(Now() & vbTab & "Exception while Emailing <redacted>: " & ex.Message & vbCrLf)
SendEmails("Error emailing <redacted>." & ex.Message & vbCrLf & ex.StackTrace)
End Try
End Sub
코드를 표시하지 않으면 Google에서 할 수있는 일이 많지 않습니다. 게시하기 전에 비밀번호와 개인 정보에서 코드를 삭제해야합니다. –