01-20-2010, 10:12 AM
Hi,
I have tried the below piece of code, i was able to send email through qtp, but i didn't wanted to invoke outlook each time, i run, so i added piece of code intially which checks whether the outlook is open.
I am facing 2 propblems over here
At line 1 iam getting general error
and also i am manually specifying the attachment path, that too isn't working, is there any way that i can change this hard coded path
Any help would be really appreciated.
Regards;
Vijay
I have tried the below piece of code, i was able to send email through qtp, but i didn't wanted to invoke outlook each time, i run, so i added piece of code intially which checks whether the outlook is open.
Code:
Set mailob = GetObject(", outlook.application")
If Not Obj Is Nothing Then
Msgbox "Outlook is already open"
Else
systemUtil.Run "OUTLOOK.EXE"
End If
Set Obj = Nothing
'systemUtil.Run "OUTLOOK.EXE" ' Comment this line, if outlook is already open
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 = "dtulasi@abc.com"
mailitm.cc = "dtulasi@xyz.com;dtulas@zyx.com"
wait(5)
mailitm.subject = "QTP Result"
wait(5)
mailitm.attachments.add ("C:\Documents and Settings\Administrator\Desktop\Test3\Res1\Report.xml") 'path of file
mailitm.send
At line 1 iam getting general error
and also i am manually specifying the attachment path, that too isn't working, is there any way that i can change this hard coded path
Any help would be really appreciated.
Regards;
Vijay