Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send mail via Gmail
#1
Not Solved
Hello All,

I am using virtual box on which i instaled QTP 10.0 evaluation version after every 14 days, now i want to send all recorded result via gmail, so can you please let me explain how i achieve this.

Hoping for cooperation

Thanks

Mahesh
Reply
#2
Not Solved
Intresting. Gmail has no API exposed for you to send a email without opening it. You will need to write a script to login- compose mail- attachment-logout and then append it to the end of your script.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#3
Not Solved
Hi basant,

Actually i had a code but it won't work can you please help me out

i call function like

Email “abc@gmail.com”, “123456″, “def@gmail.com”,”xyz@gmail.com”, “hi”, “i am mahesh”

and create two functions 1st for

Public Function Email( EmailID, Password, Recipient, CC, Subject, Body )
'—————————————————————————————————————————————
Set Email = New clsSendMail

With Email
.Send EmailID, Password, Recipient, CC, Subject, Body
End with
End Function

and second function contains whole class like

Class clsSendMail

Private oMessage 'CDO.Message Object
Private strFrom 'Sender's Email ID: XX@YY.COM
Public Body 'Body Text from Text File

'���������������������������������������������
' Name: Sub Email (Public)
'
' Purpose: Send Email Using CDO
'
' Parameters:
' sEmailID: Sender's Mail ID String
' sPassword: Sender's Password String
' sTo: Recipient's Mail ID String (Primary)
' sCC: Recipient's Mail ID String (CC)
' sSubject: Subject String
' sBody: Body Message String
'
' Return: -
'���������������������������������������������
Public Sub Send( sEMailID, sPassword, sTo, sCC, sSubject, sBody )
'���������������������������������������������
Dim oRegExp 'RegEx Object
Dim sDetails 'Report Details
Dim intStatus 'Report Status
Dim sStepName 'Report Step

'Sender ID has Class scope
Me.From = sEmailID
'Message Body
If sBody "" Then Me.Body = sBody

intStatus = micPass
sStepName = " Sent"

Set oRegExp = New RegExp
oRegExp.Global = True
oRegExp.Pattern = "||"
Set oMatches = oRegExp.Execute( Me.Body )

'Build Message
With oMessage
.Subject = sSubject
.From = sEmailID
.To = sTo
.CC = sCC
'BCC Property can be added as well:
'.BCC = sBCC
'If HTML Tags found, use .HTMLBody
If oMatches.Count > 0 Then
.HTMLBody = Me.Body
Else
.TextBody = Me.Body
End If
End With

Set oMatches = Nothing
Set oRegExp = Nothing

With oMessage.Configuration.Fields
'Sender's Mail ID
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"sendusername") = sEmailID
'Sender's Password
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"sendpassword") = sPassword
'Name/IP of SMTP Server
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"smtpserver") = cdoSMTPServer
'Server Port
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"smtpserverport") = cdoOutgoingMailSMTP
'Send Using: (1) Local SMTP Pickup Service (2) Use SMTP Over Network
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"sendusing") = cdoSendUsing
'Authentication Used: (1) None (2) Basic (3) NTLM
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"smtpauthenticate") = cdoAuthenticationType
'SMTP Server Requires SSL/STARTTLS: Boolean
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"smtpusessl") = cdoUseSSL
'Maximum Time in Seconds CDO will try to Establish Connection
.Item("http://schemas.microsoft.com/cdo/configuration/" &_
"smtpconnectiontimeout") = cdoTimeout
'Update Configuration Entries
.Update
End With

'Report Details
sDetails = "SMTP Server: " & cdoSMTPServer & vbLf
sDetails = sDetails & "Sender: " & sEMailID & vbLf
sDetails = sDetails & "Recipient: " & sTo & vbLf
sDetails = sDetails & "Server Port: " & cdoOutgoingMailSMTP & vbLf
sDetails = sDetails & "SSL Used: " & cdoUseSSL & vbLf
sDetails = sDetails & "Authentication Type: " & cdoAuthenticationType & vbLf
sDetails = sDetails & "SMTP Service Type: " & cdoSendUsing & vbLf & vbLf
sDetails = sDetails & "Subject: " & sSubject & vbLf & vbLf
sDetails = sDetails & "Body: " & sBody

On Error Resume Next
'Send Message
oMessage.Send
If Err.Number 0 Then
intStatus = micWarning
sStepName = " Not Sent"
sDetails = sDetails & vbLf & "Error Description: " & Err.Description
End If
On Error Goto 0

'If you're not using QTP, please disable the statement below:
Reporter.ReportEvent intStatus, "EMail" & sStepName, sDetails
End Sub

'���������������������������������������������
' Name: Sub LoadBodyMessage (Public)
'
' Purpose: Loads BodyText from a Text File
'
' Parameters:
' sCompleteFilePath: Complete Path to the Text File (Eg: "C:\MyDocs\MyMail.txt")
'
' Return: -
'���������������������������������������������
Public Sub LoadBodyMessage( sCompleteFilePath )
'���������������������������������������������
CONST ForReading = 1
Dim oFSO, oFile

Set oFSO = CreateObject( "Scripting.FileSystemObject" )
Set oFile = oFSO.OpenTextFile( sCompleteFilePath, ForReading )
Me.Body = oFile.ReadAll
oFile.Close: Set oFile = Nothing

Set oFSO = Nothing
End Sub

'���������������������������������������������
' Name: Class_Initialize (Private)
'
' Purpose: Binds to the CDO Object
'
' Parameters: -
'
' Return: -
'���������������������������������������������
Private Sub Class_Initialize
'���������������������������������������������
Set oMessage = CreateObject( "CDO.Message" )
End Sub

'���������������������������������������������
' Name: Class_Initialize (Private)
'
' Purpose: Release the CDO Object
'
' Parameters: -
'
' Return: -
'���������������������������������������������
Private Sub Class_Terminate
'���������������������������������������������
Set oMessage = Nothing
End Sub

'�������������������������������������
' Name: Property cdoSendUsing (Private)
'
' Purpose: Readonly property configuration for SMTP Service
'�������������������������������������
Private Property Get cdoSendUsing 'As Integer
'�������������������������������������
cdoSendUsing = 2 'Use SMTP Over The Network
'cdoSendUsing = 1 'Use Local SMTP Service Pickup Directory
End Property

'�������������������������������������
' Name: Property cdoTimeout (Private)
'
' Purpose: Maximum time in seconds CDO will try to establish a connection
'�������������������������������������
Private Property Get cdoTimeout 'As Integer
'�������������������������������������
'cdoTimeout = 15 'Seconds
cdoTimeout = 45 'Seconds
'cdoTimeout = 75 'Seconds
End Property

'�������������������������������������
' Name: Property cdoAuthenticationType (Private)
'
' Purpose: Type of Authentication to be used
'�������������������������������������
Private Property Get cdoAuthenticationType 'As Integer
'�������������������������������������
'cdoAuthenticationType = 0 'No Authentication
cdoAuthenticationType = 1 'Basic Authentication
'cdoAuthenticationType = 2 'NTML Authentication
End Property

'�������������������������������������
' Name: Property cdoOutgoingMailSMTP (Private)
'
' Purpose: Server Port
'�������������������������������������
Private Property Get cdoOutgoingMailSMTP 'As Integer
'�������������������������������������
If InStr(1, Lcase(Me.From), "@gmail") 0 Then
cdoOutgoingMailSMTP = 465
ElseIf InStr(1, LCase(Me.From), "@aol") 0 Then
cdoOutgoingMailSMTP = 587
Else
cdoOutgoingMailSMTP = 25
End If
End Property

'�������������������������������������
' Name: Property cdoSMTPServer (Private)
'
' Purpose: Name/IP of SMTP Server
'�������������������������������������
Private Property Get cdoSMTPServer 'As String
'�������������������������������������
If InStr(1, LCase(Me.From), "@yahoo") 0 Then
cdoSMTPServer = "smtp.mail.yahoo.com"
ElseIf InStr(1, LCase(Me.From), "@gmail") 0 Then
cdoSMTPServer = "smtp.gmail.com"
ElseIf InStr(1, LCase(Me.From), "@hotmail") 0 Or _
InStr(1, LCase(Me.From), "@live") 0 Then
cdoSMTPServer = "smtp.live.com"
ElseIf InStr(1, LCase(Me.From), "@aol") 0 Then
cdoSMTPServer = "smtp.aol.com"
End If
End Property

'�������������������������������������
' Name: Property cdoUseSSL (Private)
'
' Purpose: Setting for SMTP Server's use of SSL (Boolean)
'�������������������������������������
Private Property Get cdoUseSSL 'As Boolean
'�������������������������������������
cdoUseSSL = True
If InStr(1, LCase(Me.From), "@aol") 0 Then
cdoUseSSL = False
End If
End Property

'�������������������������������������
' Name: Property From (Public)
'
' Purpose: Sender's Email ID
'�������������������������������������
Public Property Let From( ByVal Val )
strFrom = Val
End Property
Public Property Get From 'As String
From = strFrom
End Property

End Class
IT won't work, can you please help me out

Thanks
Mahesh
Reply
#4
Not Solved
Honestly mahesh i am out of patience reading the code. A glance looks like you are trying to send email to your gmail id using the Outlook ?

Else, Can you please specify if it throws any error message when the function gets executed ?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to send/pass UFT Run Error Dialog as output value to main driver script lravi4u 0 328 11-05-2023, 03:55 PM
Last Post: lravi4u
  Send automatic email notification when test run started helmzshelmz 0 923 04-03-2020, 07:54 AM
Last Post: helmzshelmz
  To send Fail Results to mail Naresh 1 2,403 04-23-2015, 08:30 PM
Last Post: babu123
  To send the QTP Results to mail using Thunderbird Naresh 0 2,135 04-03-2015, 03:19 PM
Last Post: Naresh
  How to delete particular mails in Gmail using QTP rajkumarsm 1 3,860 10-06-2014, 07:03 PM
Last Post: rajkumarsm

Forum Jump:


Users browsing this thread: 1 Guest(s)