Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending Mail through QTP
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
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


Messages In This Thread
Sending Mail through QTP - by papu - 02-26-2009, 01:05 PM
RE: Sending Mail through QTP - by tarunlalwani - 02-26-2009, 01:59 PM
RE: Sending Mail through QTP - by papu - 02-26-2009, 02:59 PM
RE: Sending Mail through QTP - by tarunlalwani - 02-26-2009, 06:41 PM
RE: Sending Mail through QTP - by chaitanyaponangi - 06-17-2009, 02:43 PM
RE: Sending Mail through QTP - by v890115 - 09-02-2009, 03:16 AM
RE: Sending Mail through QTP - by basanth27 - 09-02-2009, 11:22 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Rolleyes Urgent help with Gmail Sending mail feature nidhitaneja 2 2,912 03-05-2014, 09:39 PM
Last Post: nidhitaneja
  How To pick up the particular mail in Post Login Gmail page and click on Checkbox akhandesh 0 2,838 12-02-2013, 01:35 PM
Last Post: akhandesh
  Query for configuration of Mail Body section through VB/QTP prasanna.rathinam 1 3,062 09-19-2013, 12:03 PM
Last Post: ssvali
  Object doesn't support this property or method: 'mail.unread Line(2929):"". kotaramamohana 0 2,435 09-28-2011, 06:19 PM
Last Post: kotaramamohana
  Need to send already "Opned" Mail kotaramamohana 0 2,690 09-15-2011, 01:03 PM
Last Post: kotaramamohana

Forum Jump:


Users browsing this thread: 2 Guest(s)