Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Outlook using QTP
#5
Solved: 11 Years, 4 Months, 3 Weeks ago
hello,

Basically, you have three choices for scripting emails from QTP;
1. Have QTP access a PHP script that has email functionality.
2. Have QTP use outlook objects to send email.
3. Have QTP create an email object without either of the above.

The first method works, if you can create a PHP page with a script mailer. The downside is, that it uses an web page, but it is effective.

The second method is not ideal, in my opinion. What if the PC you are executing the script on does not have outlook installed? What if the outlook isnt configured with an account? (Bad idea).

The third option seems to be the best and has worked out wonderfully. Sample function code bleow:

'**************** Send Email Function *****************************
Code:
Function SendMail(EmailAddress, MessageBody, MsgAttachment)
    Dim objMessage
    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "QTP Results - Automated Testing"
    objMessage.From = "QTPTesting@address.com" ' Change this for your own from address
    objMessage.To = EmailAddress
    objMessage.TextBody = MessageBody

' ==Include File attachments here ==
    objMessage.AddAttachment MsgAttachment
    
    '==This section provides the configuration information for the remote SMTP server.
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    '==Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "<Server Address Here>"   ' "someserver.domain.com"

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

    '==End remote SMTP server configuration section==
    objMessage.Send
End Function

Hope this helps,

Chris
Reply


Messages In This Thread
Outlook using QTP - by dsharma - 01-21-2008, 09:15 AM
RE: Outlook using QTP - by dsharma - 01-21-2008, 05:10 PM
RE: Outlook using QTP - by Rajashekar Gouda - 01-21-2008, 05:16 PM
RE: Outlook using QTP - by chrism2202 - 01-23-2008, 02:17 AM
RE: Outlook using QTP - by keyurpathak - 04-04-2008, 01:44 AM
RE: Outlook using QTP - by vamshiram - 06-25-2008, 07:09 PM
RE: Outlook using QTP - by deeps_aj - 09-23-2008, 06:43 PM
RE: Outlook using QTP - by srivania - 09-25-2008, 02:32 PM
RE: Outlook using QTP - by navyasatish - 07-18-2008, 07:21 AM
RE: Outlook using QTP - by venkatbatchu - 10-20-2009, 04:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting Email Body from Outlook waseem.khan.91 0 2,234 03-04-2019, 02:53 PM
Last Post: waseem.khan.91
  Extracting Email Body from Outlook waseem.khan.91 0 1,235 03-01-2019, 02:51 PM
Last Post: waseem.khan.91
  Unable to send an email from Outlook which is already opened as draft attiliv 0 2,260 03-24-2013, 11:14 AM
Last Post: attiliv
  Outlook automation issue - Report message in a shared mail box chsurya 0 2,715 03-11-2011, 06:33 PM
Last Post: chsurya
  MS OutLook Email Notification nelmanoj 0 2,535 12-27-2010, 01:05 PM
Last Post: nelmanoj

Forum Jump:


Users browsing this thread: 3 Guest(s)