I’m looking for a way to get the content/body of a mail using Katalon. I’ve tried using the Gmail plugin which is available in the store but it looks like it needs an update (couldn’t get it to work properly due to several errors).
Is it even possible to use Gmail in this case (as they seem to have a strict privacy policy now)?
Though you will need to go in to the security settings for the account and allow ‘Less secure app access’, otherwise any calls to authenticate will be blocked.
Obviously use your own mailbox username/pw combo: copy the text and dump it into your own keywords package/class etc.
The getLastReceivedEmailBody function has a folder.getMessages() call. That returns them in reverse order of when they were received, so newest is last.
it’s working perfectly fine with one exception: If I try to get the newest mail body, it doesn’t return the text for some reason.
This is how the code looks after I added the “newest email” part:
If I use getContent().toString on foundMessages[foundMessages.length-1] it returns the HTML code of my email but it doesn’t seem to work with your getTextFromMessage() function. Maybe I missed something here.
This might be a dead thread by now, but I have created a keyword from the javamail.txt and am struggling with what to call as my keyword. I have:
package global
public class EmailHelpers {
private Folder folder;
public enum EmailFolder {
INBOX("INBOX"),
SPAM("SPAM");
private String text;
private EmailFolder(String text){
this.text = text;
}
public String getText() {
return text;
}
}
/**
* default constructor to get the connection to our email inbox
*/
public EmailHelpers() {
// connect to our qa test email inbox
connectToInbox(GlobalVariable.automationEmail, GlobalVariable.automationPassword, EmailFolder.INBOX)
}
…and then the rest from the txt above.
I am trying to figure out what I need to call in order to connect and pull messages. I feel ridiculous as I have worked with keywords hundreds of times, but for some reason I am not figuring this out.
I am calling it: CustomKeywords.‘global.EmailHelpers.connectToInbox’(‘emailaddress@gmail.com’, ‘xxxxxxxxxxxxx’, ‘INBOX’)
Google Gmail is highly security conscious. It rejects “third-party apps”, which includes all apps that work on Selenium WebDriver, which includes Katalon Studio.
However this page tells that you can try something:
When a third-party app meets our security standards, you can:
…
Afaik connecting to a gmail inbox does not work anymore (see kazurayams reply). Right now I’m still using a modified version of this class to connect to an outlook inbox.
You need to create a new instance of the EmailHelpers class first. The constructor calls the connectToInbox method. Afterwards you can use any of the other methods to do whatever you like.
Here’s an example:
EmailHelpers eh = new EmailHelpers('INBOX')
println eh.getNewestMail()