How do we send email from QTP ?
We can send an email from a QTP testscript by using the below function. It uses CDO.Message object to perform that action. We use the SMTP Server to deliver the email message to the concerned email ID. Please update the values as per your environment. This function sends a email attachment to specified email address.
Call this function as
sendEmail(“c:\testreport.txt”, “myemail@mycompany.com”)
Function sendEmail(reportfile,sendto)
Set oMessage = CreateObject(“CDO.Message”)
‘==This section provides the configuration information for the remote SMTP server.
‘==Normally you will only change the server name or IP.
oMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2‘Name or IP of Remote SMTP Server
oMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “Your_smtp_server_name”‘Server port (typically 25)
oMessage.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25oMessage.Configuration.Fields.Update
oMessage.Subject = “Specify the subject here”
oMessage.Sender = “Your email ID”
oMessage.To = sendto
oMessage.CC = “an email ID”
oMessage.TextBody = “Please find the report attached” &vbcrlf & vbcrlf & “Thanks” & vbcrlf & “your name”
oMessage.AddAttachment reportfile
oMessage.SendSet oMessage = Nothing
End Function
3 Comments »
Leave a comment
-
Archives
- June 2009 (1)
- April 2009 (1)
- March 2009 (1)
- August 2008 (5)
- July 2008 (4)
- May 2008 (2)
- April 2008 (3)
- February 2008 (3)
-
Categories
-
RSS
Entries RSS
Comments RSS
Thank you for blog information.
Excellent information
How can i learn QTP step by step?
If you have any material to learn QTP then please guide me. I will be very thankful to you.
Hi,
Need your help, how do i convert a batch of qtp test results into excel and send via email automatically to eg. managers.?