Micro Focus QTP (UFT) Forums
Microsft Outlook Email and QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Microsft Outlook Email and QTP (/Thread-Microsft-Outlook-Email-and-QTP)



Microsft Outlook Email and QTP - siri - 01-04-2010

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


RE: Microsft Outlook Email and QTP - sreekanth chilam - 01-04-2010

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



RE: Microsft Outlook Email and QTP - Saket - 01-04-2010

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.


RE: Microsft Outlook Email and QTP - siri - 01-04-2010

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