2012-06-20 48 views
0

這裏是代碼:發送至外部電子郵件失敗

Dim SmtpServer As New SmtpClient() 
    Dim mail As New MailMessage() 
    Dim attachment As System.Net.Mail.Attachment 

    SmtpServer.Credentials = New _ 
    Net.NetworkCredential("[email protected]", "1234")  
    SmtpServer.Port = 25 
    SmtpServer.Host = "SmtpServer" 

    mail = New MailMessage() 
    mail.From = New MailAddress("[email protected]") 

    mail.To.Add("[email protected]") 

    mail.CC.Add("[email protected]") 
    mail.CC.Add("[email protected]") 

    mail.Headers.Add("Disposition-Notification-To", "[email protected]") 'Read receipt 

    mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure 'Fail delivery notification 

    mail.Subject = "Sending Documents" 

    mail.Body = "To Whom May Concern," & vbCrLf _ 
    & vbCrLf & "Please refer to the attachment for the documents." & vbCrLf & _ 
    "NOTE : This is an automatically generated email and will be sent daily." 

    For Each path As String In attch 
     attachment = New System.Net.Mail.Attachment(path) 
     mail.Attachments.Add(attachment) 
    Next 

    Try 
     SmtpServer.Send(mail) 
     SmtpServer = Nothing 

    Catch ex As Exception 
     Response.Write(ex.ToString) 
     Exit Sub 

    End Try 

問題是僅內部電子郵件接收,而不是外部電子郵件。 代碼執行過程中沒有顯示任何錯誤。 關於如何解決這個問題的任何想法? 或者我需要在Microsoft Exchange Server上配置一些東西嗎? 也是使用MailMarshal進行過濾的服務器。 高級謝謝您的貢獻反饋。

+0

我們是否可以假設你已經做了明顯的檢查並檢查了垃圾郵件/過濾器和交換日誌(認爲像是反彈等) – Kane

回答

0

確保「mail.From」值位於SMTP服務器允許的列表中。可能是中繼不允許。

相關問題