问题补充:现在的状态时循环发送50封信,如果第二封没有发送成功,后面的48封都没法发送。现在要机器重启才能
解决问题,请高手指点
Private Sub Form_Load()
Form1.Visible = True
For i = 1 To 50
    Call sendM("NJ TEST" & i, "<center>Receive Email OK<hr>Description :LLLL<center>")
Next
Unload Me
End Sub
Public Function sendM(title As String, content As String)
        Dim sFile As String
        Dim flag_num
        flag_num = 0
sendM:
        On Error Resume Next
        Set JMail = CreateObject("JMail.Message")
        JMail.Charset = "gb2312"
        JMail.From = "[email protected]"
        JMail.subject = title
        JMail.MailServerUserName = "[email protected]"
        JMail.MailServerPassword = "1234"
        JMail.Priority = 1
        JMail.AddRecipient ("[email protected]")
        'JMail.AddAttachment (sFile)
        'content ="<center>Receive Email Error<hr>Description :" & errInfo & "<center>"
        JMail.HTMLBody = content
        JMail.Body = "我们的邮件采用了HTML格式,但是您的邮件查看软件可能不支持。"
        flag = JMail.Send("smtp.excelpoint.com.cn")
        If (flag) Then
        Else
            flag_num = flag_num + 1
            If (flag_num = 5) Then
            Else
                '延迟一段时间
                waittime (60)
            GoTo sendM
            End If
        End If
        Set JMail = Nothing
End Function
Public Sub waittime(delay As Single)
  Dim starttime As Single
  starttime = Timer
  Do Until (Timer - starttime) > delay
  DoEvents
  Loop
End Sub

解决方案 »

  1.   

    估计原因:没有发送成功时,估计是挂在进程里假死了,因sendM里有逻辑死循环代码,需要用api强制从进程里关闭它,等同于重启系统
    解决:
    要修改sendM里的On Error Resume Next为 On Error goto a0 ,去掉goto返回,避免死循环
      

  2.   

    去掉goto,我如何能确保一封信发送失败的情况下重复发送
      

  3.   

    汗,发送失败肯定是有原因的,如那个邮箱名字错了或不存在,你让程序一直循环发送吗,那不成了死循环了
    如果非要保留goto返回,至少也要加个条件判断,如果返回3次发送都不成功,就跳出
      

  4.   


    你没有看到我的代码里有个flag_num变量
      

  5.   


    以后用Winsock时候,再请教你.