10-20-2009, 04:20 PM
Please find the below code u would be able to send the mail through qtp
'Email generation VB Script snipet.
'venkat batchu
'Pre requisite: MS Outlook apllication up running on the desktop
'----------------------------------------------------------------------------------
===================================================================
Enjoy by sending mails through qtp..
'Email generation VB Script snipet.
'venkat batchu
'Pre requisite: MS Outlook apllication up running on the desktop
'----------------------------------------------------------------------------------
Code:
Dim ToAddress
Dim Subject
Dim Body
Dim Attachment
Dim oUtlookApp, nAmeSpace, newMail
'SystemUtil.Run "C:\Program Files\Microsoft Office\Office11\OUTLOOK.EXE" 'This line should be enabled if the Outlook on the desktop is not running
ToAddress = "venkat.batchu@xxxx.com" ' Message recipient Address
Set oUtlookApp = CreateObject("Outlook.Application")
Set nAmeSpace = oUtlookApp.GetNamespace("MAPI")
Set newMail = oUtlookApp.CreateItem(0)
Subject = "Test Results of Login and Signoff" 'Message Subject you can update
Body = "To view the test results of login and signoff. " 'Message body you can update
newMail.Subject = Subject
newMail.Body = Body & vbCrLf
newMail.Recipients.Add(ToAddress)
newMail.Attachments.Add("C:\Documents and Settings\venkat.batchu\Desktop\Results\Log\LogFile.html") 'You can update attachment file name
newMail.Send
Set nAmeSpace = Nothing
Set oUtlookApp = Nothing
'end of the email generation code
Enjoy by sending mails through qtp..