为什么我想循环自动发送邮件的时候,就只有第一封能自动发送,其它后面的邮件都只能创建,不能自动发送Private Sub send_mail_Click() '发送邮件通知 Do While Not TDBG_Dept.EOF If A>B Then
Dim olapp As Object
Dim oitem As Object Set olapp = CreateObject("outlook.Application")
Set oitem = olapp.CreateItem(0)
With oitem
.Display
.Subject = "TEST" '主题
.To = "[email protected]" '收件人
.Body = "test" '邮件内容
DoEvents
SendKeys "%s", Wait:=True '模拟键盘确认功能
End With
Set olapp = Nothing
Set oitem = Nothing
TDBG_Dept.MoveNext
Else
Exit Sub
End If LoopEnd Sub
Dim olapp As Object
Dim oitem As Object Set olapp = CreateObject("outlook.Application")
Set oitem = olapp.CreateItem(0)
With oitem
.Display
.Subject = "TEST" '主题
.To = "[email protected]" '收件人
.Body = "test" '邮件内容
DoEvents
SendKeys "%s", Wait:=True '模拟键盘确认功能
End With
Set olapp = Nothing
Set oitem = Nothing
TDBG_Dept.MoveNext
Else
Exit Sub
End If LoopEnd Sub
直接用.Send() 方法试试