Can we automate MS Outlook Operations using QTP? We need to find out automation tools which can automate MS Outlook. Pls help.
Can we automate MS Outlook Operations using QTP? We need to find out automation tools which can automate MS Outlook. Pls help.
SendTo=".......@........com"
SendToCC=".......@........com"
Subject="QTP mail"
Body1="This mail is generated from QTP Environment"
Attachment="C:\Spec.xls"
Call SendMail(SendTo, Subject, Body1, Attachment)
Function SendMail(SendTo, Subject, Body, Attachment)
Set ol=CreateObject("Outlook.Application")
Set Mail=ol.CreateItem(0)
'ol.DisplayAlerts = False
Mail.to=SendTo
Mail.CC=SendToCC
Mail.Subject=Subject
Mail.Body=Body
If (Attachment <> "") Then
Mail.Attachments.Add(Attachment)
End If
Mail.Send
ol.Quit
Set Mail = Nothing
Set ol = Nothing
End Function
Thanks for your response.
When we try to record action on outlook, QTP records this with coordinates. Do we need to add some libraries ? OR Are we required to add some particular addin to achieve this...
currently, we are using QTP 8.2 with .Net Addin enabled. Can you please provide few more pointers on this?
Thanks,
Kavita
I have to check 60 notification that are delivered by our application to usr at different events. Each time we will check manually by stoping SMTP and verifying the mails in Pickup folder. Is there any way to read Outlook express emails with file extention .eml and verify the email notifications?
Set ol=CreateObject("Outlook.Application")
If i have try to creaet outlook object using above step its giving an error saying ActivX component cannot create object. Andy idea?
We can automate Outlook using QTP. .net addin should be installed.
Am working on an application totally automating outlook.... feel free to approach me
How we can get .net add-in?
Hi,
Can you give some idea how to read a mail from outlook express using QTP
Thanks
Hi Naga,
It looks very interesting that you solved automating MS Outlook using QTP. I need your help to start the work. I am pointing out few of my queries below:-
1. .Net addin is required for Outlook automation?
2. Is it possible to verify the body contents of the mail?
3. Do we have maintain a separate mailbox for automation?
4. Any other requirements you may know that will required for QTP?
Currently i am using QTP 9.5.
1. .Net addin is required for Outlook automation?
Not necessary
2. Is it possible to verify the body contents of the mail?
Yes you can verify all the contents of a mail
3. Do we have maintain a separate mailbox for automation?
NO
4. Any other requirements you may know that will required for QTP?
Default QTP installation is enough to automate Outlook
hai friend,
While installing QTP it asks for addins you can select .Net addin there if needed. I don't think so we need .Net addin for outlook automation.
Yes it is possible
not necessarily
Please let us know what you are looking for.
Thanks
Deepa
Thanks Naga for your reply.
To be very specific, i want to know how can verify an email i:e the sender,subject,body.
If you can help me then it would be very kind of you.
Deepa, thanks for your reply.
Actually i want verify an email by validating the sender,subject and body. Our system generates an email for an event. So we need to verify the same using QTP.
Hai friend,
Some hints if an email is generated you know to whom you are sending the email so do one thing get all the senders name, subject and so on what ever you want in a datatable and then do a loop.
This is my assumption let me know how it works out.
Thanks
Deepa
Deepa....thanks again...whatever you suggest we can go ahead but the real issue we face is how can we make QTP identify Outlook objects or how to work with the outlook object model to verfiy an email(sender,sub,body)....
It would very helpful for me if you can provide me any sort of input for this.
Hai arijit2111,
Set OutlookApplication = CreateObject("Outlook.Application")
Set Mail = OutlookApplication.CreateItem(0)
Mail.To = "abc@test.com" 'Enter your mail id here
Mail.Subject = "test"
Mail.Body = "this is a test"
Mail.display
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys("%s")
Set Mail = Nothing
In the above code you can view to whom you are sending the mail, subject and with this statement "Mail.display" the mail will be opened in the front end. Grab to, subject and body from the mail and store the values in variable.
Open an excel sheet it should contain to, subject, body to verify to whom the mail will be sent. So you can compare excel sheet with the values you have already stored in a variable.
Thanks
Deepa
Hi,
I have 1 req.. say a mail is send to my outlook from my application..
i want to open that mail from my inbox and check its TO list, CC list, Body and Subject fields against a standard template..
can u plss tell me how to do it ASAp.. its quite urgent
Hi,
I have to automate outlook using qtp. I am using qtp 9.5. I have to read each content of an email on outlook like sender content, cc field content, subject content, attachment file name and file content , body content.
mails will be selected on search criteria.
I need methods and properties used for accessing outlook objects.
Please help me regarding this.
Hi
Can you please check if you are able to retrieve the body and subject of the unread mails using the below code,
Set olapp = createobject("outlook.application")
set inbox = olapp.getnamespace("mapi").folders
for each fold in inbox
msgbox fold.name
getsubfolders(fold)
next
msgbox inbox.count
sub getunreadmails(objfolder)
set col = objfolder.items
for each mail in col
if mail.unread then
msgbox mail.subject
msgbox mail.sendername
msgbox mail.body
msgbox mail.senton
mail.unread=false
end if
next
end sub
sub getsubfolders(objparentfolder)
set colfolders = objparentfolder.folders
for each objfolder in colfolders
set objsubfolder = objparentfolder.folders(objfolder.name)
if objfolder.name<>"notes" then
getunreadmails(objfolder)
end if
getsubfolders objsubfolder
next
end sub
1) Copy the above script into QTP(any version)
2) try to Execute the script, it will show the unread mails information(sender, date, body, subject...etc)
Modify the above code according to your requirement
Work great! how do you specify to read just one email based on the subject or sender or sent date/time?