标题: 关于选择outlook对话框的代码 [打印本页] 作者: hlaissy 时间: 2009-7-15 13:44 标题: 关于选择outlook对话框的代码 下面是用VBS编写的关于QTP自动发送Email的代码:
Function SendMail(SendTo, Subject, Body, Attachment)
Set ol = CreateObject("Outlook.Application")
Set Mail = ol.CreateItem(0)
Mail.to = SendTo
Mail.Subject = Subject
Mail.Body = Body
If(Sttachment <> "") Then
Mail.Attachments.Add(Attachment)
End If
Mail.Send
ol.Quit
Set Mail = Nothing
Set ol = Nothing
End Function
Function SendMail(SendTo, Subject, Body, Attachment)
Set ol = CreateObject("Outlook.Application")
Set Mail = ol.CreateItem(0)
Mail.to = SendTo
Mail.Subject = Subject
Mail.Body = Body
If(Sttachment <> "") Then
Mail.Attachments.Add(Attachment)
End If
Mail.Send
' ol.Quit
Set fso = CreateObject("WScript.shell")
While fso.AppActivate("Microsoft Outlook") =FALSE
WScript.sleep 1000
Wend
fso.SendKeys "a",True
fso.SendKeys "y",True
wscript.sleep 7000
While fso.AppActivate ("Microsoft Outlook") =FALSE
WScript.sleep 1000
Wend
fso.SendKeys "y",True
Set Mail = Nothing
Set ol = Nothing
End Function