Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 21061

Why Isn't my Code Working? Opening Outlook in Python Script

$
0
0

I have a basic script that I found that should open Microsoft Outlook and read the last email received, then log the contents of the body. I keep getting a runtime error saying "Member Not Found." I have combed through every thing that is out there about OleObject and COM objects and must admit that the literature is pretty confusing. On a basic level, are these things recognized by TestComplete out of the box or do I need to install some other plugin/add-on somewhere for this to be recognized?

 

I have went through the Object Browser, located the Outlook process, and examined the Properties in Advanced View. There is no OleObject field listed. Any help is appreciated. Thank you!

 

 

def check_email():
  msOutlook = Sys.OleObject("Outlook.Application").Activate

  inbox = msoutlook.GetDefaultFolder(6) # "6" refers to the index of a folder - in this case,
                                    # the inbox. You can change that number to reference
                                    # any other folder
                                    
  messages = inbox.Items
  message = messages.getLast()
  body_content = message.body
  
  Log.Message(body_content)

 


Viewing all articles
Browse latest Browse all 21061

Trending Articles