set objoutlookmail=createobject("outlook. application")
Set mymail=objoutlookmail. createitem(0)
mymail.display
set mymailproperty=objoutlookmail. activeinsepector
if mymailproperty. iswordmail="trur" then
set mydoc=mymailproperty. wordeditor
mydoc. range chr(13)+"Hi All," +chr(13) & " Please see execution status for.... application." +chr(13)
mydoc.range.insertafter chr(13)+"Regards,"+chr(13) & "support team" +chr(13)
strmailattachment="c:\test. html"
mymail. Attachments. add strmailattachment
mymail. from="abc@gmail.com"
mymail. to="xyz@gmail.com;pyz@gmail.com"
mymail. subject="Application Automation Execution Reports"
mymail. send
end if
Set mymail.=Nothing
Set mydoc=Nothing
Set objoutlookmail=Nothing
Tuesday, December 18, 2018
Send email through vbs using Outlook Application utility object
Tuesday, November 27, 2018
Test Complete- Search data in csv or text file
public function searchdatainfilr()
strfilepath="c:\test. csv
set objfso=createobject(" scripting. filesystemobject")
set infile=objfso. opentextfile("strfilepath")
set outpath=objfso. opentextfile(strfilepath & ". tmp", 2,true)
dim irowcnt
irowcnt=0
do while not infile. atendofstream
line=inline. readline
fullfile=fullfile & line
loop
log. message fullfile
if instr(fullfile, "searctxtval") >0 then
log. message "validation pass"
else
log. message "validation fail"
end if
infile. close
outfile. close
objfso. deletefile(strfilepath l
objfso. movefile strfilepath & ". tmp", strfilepath
end function
Tuesday, November 20, 2018
Test Complete- Move file from source to destination
function fnMovefile(Sourcepath, destinationpath)
'path given till folder level only
' code to find csv file from particular location
set foundfiles=aqfilesystem. findfiles(sourcepath, "*.csv")
if not foundfiles is nothing then
while foundfiles. hasnext
set afile=foundfiles. next
var_foundfiles=afile. name
wend
else
log. message "no files were found"
end if
call aqfilesystem. copyfile(soyrcepath, deatinationpath)
nowtime=aqdatetime. time()
nowtime=aqstring(nowtime, ":", "_")
nowtime=aqstring(nowtime, "pm", "_")
nowtoday=aqdatetime. today()
nowtoday=aqconvert. vartostr(nowtoday)
nowtoday=aqstring.replace(nowtoday,"/","_")
destinationfile=destinationpath & "\" & varfoundfiles
destinationfilerename=destinationpath & "\" & nowtine & "_" & nowtoday & "_" & varfoundfiles
call aqfile. rename(destinationfike, desti ationfilerename)
log. message " move file with rename successfully"
end function
Test Complete - Find value is present in excel sheet or not
function searchdatainexcel(strpath, searchcol, searchval)
path="c:abc. xls"
set searchdata=DDT. exceldriver(strpath, "sheet1", true)
do while not searchdata. EOF
if aqconvert. vartostr(searchdata. value(searchcol)) =searchvalue then
blnflag=true
exit do
else
blnflag =false
end if
searchdata. next
loop
if blnflag =true then
log. message "record match"
else
log. message "record not match"
end if
end function