Forum Discussion

royd's avatar
royd
Regular Contributor
8 years ago

How do I access security code from email (web mail)?

Patients received two separate email after signing up with the hospital. One contains the link to the page where they can login. The second email contains a security code. Using TestComplete 12 with ...
  • shankar_r's avatar
    8 years ago

    Here you go,

     

    If you call  getSecurityCode() then you will get return value as your security code

     

     

    function test()
    {
     Log.Message(getSecurityCode("<Your Message body text>"))
    }

     

     

     

     

    function getSecurityCode(str_EmailBody)
    {
          
          var staticStringStart = "access code is ";
          var staticStringEnd = ". You will";
          
          var startPos = aqString.Find(str_EmailBody,0,false) + aqString.GetLength(staticStringStart);
          var endPos = aqString.Find(str_EmailBody,staticStringEnd,0,false);
          
          Log.Message(aqString.SubString(str_EmailBody,startPos,endPos - startPos));
          return aqString.SubString(str_EmailBody,startPos,endPos - startPos);
    }