Micro Focus QTP (UFT) Forums
Sending Mail through QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Sending Mail through QTP (/Thread-Sending-Mail-through-QTP)



Sending Mail through QTP - papu - 02-26-2009

Hi All,
I Am trying to send mail using QTP(9.2) .I have used "outlook.application" and also "CDONTS.Newmail".
In both cases am geting an error in the line 'Set Ol = Createobject("Outlook.Application")', saying Activex can't create object "Outlook.Application".Similar in "CDONTS.Newmail".

I have also copied the same code provided by qtp in the samplecode folder,.vbs file.But the result is same.

Please help.


RE: Sending Mail through QTP - tarunlalwani - 02-26-2009

You need to install CDonts library first. Search on microsoft.com for CDONTS library and install the same


RE: Sending Mail through QTP - papu - 02-26-2009

Thanks a lot.But what about outlook ? It is there in my machine and before executing the QTP script , have also opened outlook.


RE: Sending Mail through QTP - tarunlalwani - 02-26-2009

You are not using OUtlook here. CDONTS is a different library and it does not come with outlook.


RE: Sending Mail through QTP - chaitanyaponangi - 06-17-2009

Why install CDONTS and all???
u can use outlook.application
and also u can also use CDO.Message if u know the SMTP server name....
here are the scripts for both the cases::


1.
Code:
OUTLOOK.APPLICATION
Set objapp = createobject("outlook.application")
Set obj = objapp.createitem(0)
obj.subject = "QTP test mail"
obj.to = "<email>"
'obj.CC = "<email>"
obj.body = "This mail is send through QTP"&chr(13)&"Regards,"&chr(13)&"Test"
'obj.attachments.add("<filepath>")
obj.send


2.
Code:
CDO.MESSAGE
'Script to send an email through QTP nice one
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") ="<mail server url>"

'Server port (typically 25)
oMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

oMessage.Configuration.Fields.Update
oMessage.Subject = "Test Mail"
oMessage.Sender = "<email>"
oMessage.To ="<email>"
'oMessage.CC = "<email>"
'oMessage.BCC = "<email>"
oMessage.TextBody = "Test Mail from QTP"&vbcrlf&"Regards,"&vbcrlf&"Test"
oMessage.Send

Set oMessage = Nothing[hr]
For working on either of the above methods, ActiveX is not sufficient. Check the Visual Basic Add in at startup of QTP



RE: Sending Mail through QTP - v890115 - 09-02-2009

Hi everyone,

I wanted QTP to email me when there's a problem found during testing. I got the email codes but how do I call those codes to send email emails? Do I have to add those send email function into the testing script? Or keep the send email in a separate vbs file?

I hope this makes sense if not please let me know so I can explain more what I am seeking

Thanks...


RE: Sending Mail through QTP - basanth27 - 09-02-2009

v890115 -
Please ensure you do not Reopen Posts which are old. If you have a question kindly first search the forum and if you could not find what you were looking for then open a new post.
It is imperative that you follow the forum guidelines so that everyone can help you.

Thread locked !!!