User Tag List

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Oct 2004
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Validating that email has been sent?

    I'm currently evaluating Robot and QTP and am very new to testing in general, so please bear with me.

    My plan for evaluation is to create a test plan for our new website's Contact Us page. It's basically a page that uses HTML forms where the user fills in information (name, email, etc...). The submit button is a JavaScript function that runs through some checks and, I assume, sends an email. I'd like to verify that the email has actually gone. Is this possible? I'm not looking for a code example, I'm just not sure if QTP provides that kind of functionality.


  2. #2
    Join Date
    Aug 2004
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Re: Validating that email has been sent?

    Hello NEWVERN,

    You can do that with QTP, we will need to write some code in VBScript. We your JavaScript is using client's outlook to send the mail then you can check whether the mail has been sent or not. Try the following code,
    'This is actually VB Code
    'You can use it in VBScript also
    'The follwing variable declarion is disabled as
    'you can declare variables in this way in VBS

    'Dim objSess As MAPI.Session
    'Dim objMsg As Message
    'Dim objSentMsg As Message
    'Dim objMyField As Field
    'Dim objMessColl As Messages
    'Dim objMsgFilter As MessageFilter
    'Dim objInfoStores As InfoStores
    'Dim objRootFolder As Folder
    'Dim objFolders As Folders
    'Dim objSentItems As Folder
    'Dim objOutbox as Folder

    Set objSess = CreateObject("mapi.session")
    objSess.Logon "sai" 'Put a valid profile name here.
    Set objOutbox = objSess.Outbox
    Set objMsg = objOutbox.Messages.Add
    'Add some default data to your message before showing it to the user.
    With objMsg
    .Text = "This is my text."
    .Subject = "This is my subject."
    .Recipients.Add "sai@xxe.com" 'Put a valid
    'recipient name here.
    End With

    ' Add a dummy field with unique content to the message object
    ' to identify the message, later on. If guaranteed uniqueness is
    ' important a GUID would be more appropriate but for simplicity we
    ' will use the current "system date and time" for the content of the
    ' field
    Mytime = Now
    Set objMyfield = objMsg.Fields.Add("MyField", 8)
    objMyfield.Value = Mytime
    myfieldID = objMyfield.ID

    ' Save the changes you made to the message.
    objMsg.Update 'refreshobject:=True

    ' Display the message window.
    objMsg.Send 'ShowDialog:=True

    ' Get the "Sent Items" Folder
    ' Note: If you use CDO 1.2 or CDO 1.21 library, you can get the "Sent
    ' Items" folder by simply calling GetDefaultFolder method of the
    ' Session object as follows. If this is the case, uncomment the
    ' following line of code and comment out the lines in between ' *\*
    ' and ' */*

    'Set objSentItems = objSess.GetDefaultFolder(3)

    ' *\*
    Set objInfostore = objSess.InfoStores
    CountInfoStores = objInfostore.Count
    FoundMailbox = False
    For i = 1 To CountInfoStores
    If Mid(objInfostore(i), 1, 7) = "Mailbox" Then
    FoundMailbox = True
    Set objRootFolder = objInfostore(i).RootFolder
    Set objFolders = objRootFolder.Folders
    For j = 1 To objfolders.Count
    If objFolders(j).Name = "Sent Items" Then
    Set objSentItems = objFolders(j)
    Exit For
    End If
    End If
    If FoundMailbox = True Then
    Exit For
    End If
    ' */*

    Set objMessColl = objSentItems.Messages
    Set objMsgFilter = objMessColl.Filter

    ' Setup a filter that passes only messages with the dummy field .
    objMsgFilter.Fields(myfieldID) = Mytime
    For Each objSentMsg In objMessColl
    MsgBox objSentMsg.Subject
    Msgbox objSentMsg.Text

    Set objSentMsg = Nothing
    Set objMyField = Nothing
    Set objMessColl = Nothing
    Set objMsgFilter = Nothing
    Set objSentItems = Nothing
    Set objOutbox = Nothing

    ' Comment out the following lines if you used the GetDefaultFolder
    ' Method.

    ' *\*
    Set objInfoStore = Nothing
    Set objRootFolder = Nothing
    Set objFolders = Nothing
    ' */*

    Set objSess = Nothing




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:49 AM.

Copyright BetaSoft Inc.