Forum Discussion

BTscott's avatar
BTscott
Contributor
4 years ago
Solved

How to write a test case that requires TestComplete to access and retrieve text from an e-mail

I am currently working on a keyword test that needs to provide a verification code from an e-mail address in order to login to my site. I originally had this test case set up to navigate to google gmail and read the e-mail, but it no longer appears to be working. I suspect there is a better approach to dealing with this scenario since it relies heavily on a 3rd party (Google). I am open to using a different e-mail (ie. Microsoft Outlook), but I would like to know if there is a best practice for handling these situations where MFA verification codes are required to login/verify e-mail.

  • The best is to use a mail system having the option to automatically save newx email as text file in specified folder. Thus you can simply parse a text file on disk to have your code.

    On Outlook you have sone addins which does that but you must buy it.

     

    Another solution is to use REST API of Outlook to get your mail yourself and analyse the mailItem element.

    https://docs.microsoft.com/fr-fr/graph/api/resources/mail-api-overview?view=graph-rest-1.0

     

    Others solutions implying GUI aren't reliable.

     

     

     

3 Replies

  • BenoitB's avatar
    BenoitB
    Community Hero

    The best is to use a mail system having the option to automatically save newx email as text file in specified folder. Thus you can simply parse a text file on disk to have your code.

    On Outlook you have sone addins which does that but you must buy it.

     

    Another solution is to use REST API of Outlook to get your mail yourself and analyse the mailItem element.

    https://docs.microsoft.com/fr-fr/graph/api/resources/mail-api-overview?view=graph-rest-1.0

     

    Others solutions implying GUI aren't reliable.

     

     

     

      • KCarper's avatar
        KCarper
        Occasional Contributor

        I have a similar issue.  I was using outlook, and it was mostly accurate, however, I would be interested in a more robust solution.   Would you mind sharing how you solve this using the outlook rest-api and which requests worked for you.  

        Thank you