06-17-2009, 02:43 PM
(This post was last modified: 06-17-2009, 02:44 PM by chaitanyaponangi.)
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.
2.
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