haripotter’s technorati

Just another WordPress.com weblog

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”) = 25

oMessage.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.Send

Set oMessage = Nothing

End Function

August 8, 2008 - Posted by haripotter | General, HP Quality Center and QTP | , , , | 3 Comments

3 Comments »

  1. Thank you for blog information.

    Comment by shel kale | August 11, 2008 | Reply

  2. 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.

    Comment by softquality | February 12, 2009 | Reply

  3. Hi,
    Need your help, how do i convert a batch of qtp test results into excel and send via email automatically to eg. managers.?

    Comment by Mafatshe | July 8, 2009 | Reply


Leave a comment