关于在QTP中自动发邮件的问题
在QTP脚本执行完毕后自动发邮件,我调用的是outlook对象,但是发邮件时总会有一个安全警告提示(outlook2003),需要人工确认,有什么办法可以不弹出这个警告呢? 不知道你的程序怎么写的,假如是不定期的提示可以用场景恢复来处理,假如是每次的话,就在脚本里面控制。发一段脚本给你参考吧:
SystemUtil.Run "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE"
wait(20)
If Dialog("Enter Password").Exist(10) Then
wait(5)
Dialog("Enter Password").Activate
Dialog("Enter Password").WinEdit("Edit").Set "user"
Dialog("Enter Password").WinEdit("Edit").Type micTab
Dialog("Enter Password").WinEdit("Edit_2").Set "domain"
Dialog("Enter Password").WinEdit("Password:").SetSecure "pwd"
Dialog("Enter Password").WinButton("OK").Click
end if
wait(5)
Set Wshshell = CreateObject("Wscript.Shell")
set mailob = createobject("outlook.application")
wait(5)
set mailitm = mailob.createitem(0)
wait(5)
mailitm.display 'this being an optional step
wait(5)
mailitm.to = "to email id"
wait(5)
mailitm.subject = "subject"
wait(5)
SRGET = "SS_SR"&Date&Time
mailitm.body = "ACT_SR_SR" & date & time
mailitm.body = "" + VBCR + "Allegro Design Entry HDL" + VBCR + VBCR + "" + VBCR + "Allegro Design Entry HDL" + VBCR + VBCR + "" + VBCR + "15.5.1" + VBCR + VBCR + "" + VBCR + "Wintel" + VBCR + VBCR + "" + VBCR + "Win 2000" + VBCR + VBCR + "" + VBCR + "2-Important" + VBCR + VBCR + "" + VBCR + "2580968" + VBCR + VBCR + "" + VBCR + SRGET
myitem.attachments.add "path of the file"
mailitm.send
WshShell.sendkeys "^~"
wait(20)
Set Wshshell = CreateObject("Wscript.Shell")
Window("Microsoft Outlook").Activate
Window("Microsoft Outlook").WinTreeView("SysTreeView32").Type micCtrlDwn + micShiftDwn + "f" + micShiftUp + micCtrlUp
Window("Microsoft Outlook").Activate
Window("Advanced Find").Activate
Window("Advanced Find").WinEdit("Search for the word(s):").Set "Email List"
WshShell.sendkeys "~"
Wait(10)
Window("Microsoft Outlook").Activate
Window("Advanced Find").Maximize
Window("Advanced Find").Activate
WshShell.sendkeys "^o"
Wait(5)
Window("Message (Rich Text)").Activate
WshShell.sendkeys "^d"
Wait(5)
Window("Advanced Find").Activate
WshShell.sendkeys "%{F4}"
~~~~~~~~~~~~~~~~~~~~~
希望对你有帮助。 学习一下
thanks
太好了正需要
太好了正需要 up 回复 1# guozilu我也遇到类似问题啦,请问各位有没有解决方法呀?
发邮件时总会有一个安全警告提示(outlook2003),需要人工确认,有什么办法可以不弹出这个警告呢?代码如下:
Function SendEmail(SendTo, Subject, Body, Attachment)
Dim objOutlook
Dim objOutlookMsg
Dim olMailItem
' Create the Outlook object and the new mail object.
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set mapi = objOutlook.GetNameSpace("MAPI")
' Define mail recipients
objOutlookMsg.To = SendTo
' Body of the message
objOutlookMsg.Subject = Subject
objOutlookMsg.Body = Body
If (Attachment <> "") Then
objOutlookMsg.Attachments.Add(Attachment)
End If
'Display the email
objOutlookMsg.Display
' Send the message
objOutlookMsg.Send
' Release the objects
'objOutlook.quit
Set objOutlook = Nothing
Set mapi = Nothing
End Function 学习了, 期待答案~~~ :)
页:
[1]