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 Jscript and pretty new to scripting.
I am using mailinator.com to access the emails. So far, I have successfully managed to click on the link for sign-up. Currently I am trying to figure out how to retrieve the security code from the second email. The security code email message contains the following message:
"Your AMG - Facility forms access code is 22RP3DPM. You will receive a link to your forms using your primary email address. You will need this access code to use the forms link. Further instructions will be available after using the access code to access the forms."
The text in blue remains constant in every message. The string in red (access code) is assigned dynamically. I'm trying to figure out how to get the access code from this message.
I really appreciate any help I can get.
Thanks
Dave
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); }