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
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.?
Hi Hari,
This document looks good.
I have a doubt here.
i have configured outlook in my system.
in the place of ‘Your_smtp_server_name’ , what i need to put?
You have setup a simple SMTP server for automation purposes. See below URLs for help.
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
http://www.ehow.com/how_4489548_set-up-smtp-server-windows.html
I have created similar function for sending emails.
Attaching the link.
http://bharath-marrivada.blogspot.com/2010/02/how-to-send-email-with-attachments.html
Nice blog for QTP.Read our eBook for learning Software Testing And QTP @ http://qualitypointtech.net/ebook/
Hi Hari,
Do you have the same type of information for reading mails from a pop server.
Now I’m able to send mail but not to read them thru my pop connection.
thanks in advance
THanks a Lot, this is really helpful