在 UFT 中,我使用 VBScript 编写了电子邮件功能,但电子邮件没有从我的邮箱触发。它是从 SBGalert@.co.za 触发的,而我也提到了来自地址。
请协助我修复电子邮件以从我的邮箱触发到利益相关者。我正在使用 Outlook 15。
请在下面找到我的代码以进行检查和帮助。
Function Email
'Dim ToAddress
'Dim Subject
'Dim Body
Dim Attachment
Dim oUtlookApp, nAmeSpace, newMail
Dim fso, TextFile
SystemUtil.Run "C:\Program Files\Microsoft Office 15\root\office15\OUTLOOK.EXE" 'This line should be enabled if the Outlook on the desktop is not running
If strMailID_From <> "abc@<abc>.co.za" Then
FromAddress = strMailID_From
Else
FromAddress = "abc@<abc>.co.za"
End If
ToAddress = "abc@<abc>.co.za" ' Message recipient Address
Set oUtlookApp = CreateObject("Outlook.Application")
Set nAmeSpace = oUtlookApp.GetNamespace("MAPI")
Set newMail = oUtlookApp.CreateItem(1)
Subject = "This is a test mail" 'Message Subject you can update
'For Creating File System Object
Set fso = Createobject ("Scripting.FileSystemObject")
'For Opening the Report File in Append Mode
Set TextFile = fso.OpenTextFile(strPath & "results.html" , 8, True)
strExecutionTimeFormate=Replace(strExecutionTime,"-",":")
TextFile.Write "<html><head><title>VAF -S2K - Automation Execution Consolidated Result</title></head>"
TextFile.Write "<body bgcolor=#3D5FA3><table width=100% bgcolor=#FFFFFF border=2 cellpadding=2 cellspacing=1>"
TextFile.Write "<tr bgcolor=#CBD9F4></td><td bgcolor=#CBD9F4 width = 100%><div align=center><font color=purple><font size=5><p><strong>Automation Execution Consolidated Results</strong></p><font color=purple><font size=5><p><strong><font size=3>Execution Date -"&strExecutionDate&" Execution Time :"&strExecutionTimeFormate&" [HH:MM:SS]</strong></p></td></div></tr>"
TextFile.Write "<body bgcolor=#3D5FA3><table width=100% bgcolor=purple border=1 cellpadding=3 cellspacing=1>"
TextFile.Write "<tr bgcolor=#CBD9F4></td><td bgcolor=#CBD9F4 width = 100%><div align=center><font color=purple><font size=5><font size=3><p><strong>Portfolio : VAF   ||   Application : S2K   ||   Environment : SIT 1   ||   Project : Sanity Testing</strong></td></Table>"
TextFile.Write "<body bgcolor=#3D5FA3><table width=100% bgcolor=purple border=1 cellpadding=3 cellspacing=1>"
TextFile.Write "<tr><td bgcolor=white width = 20%><div align=Center><font color=Black><strong>APPLICATION</td><td bgcolor=white width = 45%><div align=Center><font color=Black><strong>TEST CASE NAME</td><td bgcolor=white width = 20%><div align=Center><font color=Black><strong>TEST CASE STATUS</td><td bgcolor=white width = 15%><div align=Center><font color=Black><strong>RUN TIME</td></Table>"
TextFile.Write "<body bgcolor=#3D5FA3><table width=100% bgcolor=purple border=1 cellpadding=3 cellspacing=1>"
'||   Cycle : 1  
'TextFile.Write "<tr bgcolor=#IBD9F4></td><td bgcolor=#IBD9F4 width = 100%><div align=center><font color=purple><font size=5><p><strong>Automation Execution Consolidated Results</strong></p><font color=purple><font size=5><p><strong><font size=3>Execution Date -"&strExecutionDate&" Execution Time :"&strExecutionTimeFormate & "</strong></p><font color=purple><font size=3><p><strong>Portfolio : Self Service Channel Application : Internet Banking Cycle : 1 Project : Regression Testing</strong></td></div></tr>"
TextFile.Close
newMail.Subject = Subject
newMail.Body = Body
newMail.Recipients.Add(ToAddress)
newMail.Attachments.Add(strPath & "results.html") 'You can update attachment file name
newMail.Send
Set nAmeSpace = Nothing
Set oUtlookApp = Nothing
End Function