Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Microsft Outlook Email and QTP
#1
Not Solved
Hi All,

I am trying to write a script which will automate the process of readign emails from QTP and attaching it to Qtp .

Process is like below
1.Record a proecess of the application
2. Request gets submitted
3. Manager gets an email for approval

So the manger email should be captured and placed in QTP .

So i have tried writing a scritps which will read the emails from Microsoft outlook

script is as below :
Code:
Set olApp = CreateObject("Microsoft.outlook")
Set olns = olApp.GetNameSpace("MAPI")
Set objFolder = olns.GetDefaultFolder(2)
For each item 1 in objFolder.Items
If item 1.Unread Then
msgbox item 1.body
EndIf
Next

"Error" :
"Expected 'In'
Line[1]: "For each item 1 in objFolder.Items".

help me out with this issue ASAP
help needed
Reply
#2
Not Solved
Hi Siri,

Try with the below.

Code:
Set olApp = CreateObject("Microsoft.Outlook")
Set olns = olApp.GetNameSpace("MAPI")
Set objFolder = olns.GetDefaultFolder(2)
For each item in objFolder.Items
    If item.Unread Then
        msgbox item.body
    EndIf
Next
Reply
#3
Not Solved
first of all refrain yourself from using A S A P or U R G E N T in your posts, refer posting guidelines

Can you tell us what is '1' in your statement 'For each item 1 in objFolder.Items' your answer is in the answer to your question
remove the space between item and 1 or remove the 1 from all statements
Hey Sreekanth,
very sorry, I dint noticed that you have already replied.

Reply
#4
Not Solved
Hi Sreekanth ,

When i am trying to use ur code
Code:
Set olApp = CreateObject("Microsoft.Outlook")
Set olns = olApp.GetNameSpace("MAPI")
Set objFolder = olns.GetDefaultFolder(2)
For each item in objFolder.Items
    If item.Unread Then
        msgbox item.body
    EndIf
Next

Error :Expected EndIf statement is poping up on my qtp screen
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting Email Body from Outlook waseem.khan.91 0 2,174 03-04-2019, 02:53 PM
Last Post: waseem.khan.91
  Extracting Email Body from Outlook waseem.khan.91 0 1,192 03-01-2019, 02:51 PM
Last Post: waseem.khan.91
  Find the email using subject with the help of vb script Raheem Shaik 0 1,696 12-12-2018, 02:57 PM
Last Post: Raheem Shaik
  Cannot attach the text file to email arpan 2 3,423 07-19-2013, 12:13 AM
Last Post: arpan
  Unable to send an email from Outlook which is already opened as draft attiliv 0 2,237 03-24-2013, 11:14 AM
Last Post: attiliv

Forum Jump:


Users browsing this thread: 1 Guest(s)