0

这是代码:

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

    SmtpServer.Credentials = New  _
    Net.NetworkCredential("administrator@company.com", "1234")    
    SmtpServer.Port = 25
    SmtpServer.Host = "SmtpServer"

    mail = New MailMessage()
    mail.From = New MailAddress("user@company.com.my")

    mail.To.Add("recipient@external.com")

    mail.CC.Add("user1@company.com")
    mail.CC.Add("user2@company.com")

    mail.Headers.Add("Disposition-Notification-To", "user1@company.com")   '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 进行过滤。非常感谢您提供反馈。

4

1 回答 1

0

确保“mail.From”值在 SMTP 服务器允许的列表中。可能是不允许中继。

于 2012-06-20T20:46:27.217 回答