В UFT я написал функцию электронной почты с помощью VBScript, но электронная почта не запускается из моего почтового ящика. Это срабатывает от [email protected], хотя я также упомянул адрес отправителя.
Пожалуйста, помогите мне исправить электронное письмо, которое будет запускаться из моего почтового ящика заинтересованным сторонам. Я использую 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