你是在自己的机器上吧!
可能是你的机器没有配制smtp等服务!
你到一个支持mail的服务器上再试试吧!

解决方案 »

  1.   

    我是通过web service 在服务器调用一个function,而服务器上是有smtp服务的(服务器是E文win2k server)
      

  2.   

    这个web service是自己写的(用来练习)还是调用别人的,
     web service写的肯定对吗?
      

  3.   

    请大家看看(特别是afengsunwin(afeng) )谢谢        Public Function SendEmail(ByVal sMailARL As ArrayList) As Boolean            Dim mailMsg As New MailMessage()
                Dim arlAttached As ArrayList
                Dim bReturn As Boolean            '************************************************
                Dim services() As ServiceController = ServiceController.GetServices
                Dim service As ServiceController
                Dim blnHasSmtpService As Boolean = False            ' Loop through all the services on the machine and find the SMTP Service.
                For Each service In services
                    If service.ServiceName.ToLower = "smtpsvc" Then
                        blnHasSmtpService = True
                        Exit For
                    End If
                Next            If Not blnHasSmtpService Then
                    Throw New Exception("You do not have SMTP Service installed on this " & _
                        "machine. Please check the Readme file for information on how " & _
                        "to install SMTP Service.")
                End If            ' Ensure the SMTP Service is running. If not, start it.
                If Not service.Status = ServiceControllerStatus.Running Then
                    'Dim frmStatusMessage As New frmStatus()
                    'frmStatusMessage.Show("SMTP Service not currently running. " & _
                    '    "Starting service...")
                    Try
                        service.Start()
                        'frmStatusMessage.Close()
                    Catch                    throw new Exception("There was an error when attempting " & _
                            "to start SMTP Service. Please consult the Readme " & _
                            "file for more information.")
                    End Try
                End If            '*************************************************
                With mailMsg
                    .From = CStr(sMailARL(0))
                    .To = CStr(sMailARL(1))
                    .Cc = CStr(sMailARL(2))
                    .Bcc = CStr(sMailARL(3))
                    .Subject = CStr(sMailARL(4))
                    .Body = CStr(sMailARL(5))
                    .Priority = CType(sMailARL(6), MailPriority)                'arlAttached = CType(sMailARL(7), ArrayList)
                    'If Not IsNothing(arlAttached) Then
                    '    Dim mailAttachment As Object
                    '    For Each mailAttachment In arlAttached
                    '        .Attachments.Add(mailAttachment)
                    '    Next
                    'End If
                End With
                ' See the Readme file for more information.
                SmtpMail.SmtpServer = "dev-server"            ' Use structured error handling to attempt to send the email message and 
                ' provide feedback to the user about the success or failure of their 
                ' attempt.
                Try
                    SmtpMail.Send(mailMsg)                bReturn = True
                Catch exp As Exception
                    Throw New Exception("The following problem occurred when attempting to " & _
                        "send your email: " & exp.Message)
                    Return False
                End Try
                Return bReturn
            End Function
      

  4.   

    搞定了,只要将SmtpMail.SmtpServer = ""就可以了,它可以调用本地的smtp报务