Skip to main content

Create an App Password for an Outlook account and use in service suite script to login to account with 2FA enabled.

  1. Log in to your Outlook account and Create an App password.

  2. To create a new app password for an app or device, follow the below steps. You can repeat these steps to create an app password for as many apps or devices as you need.

    1. Go to the >Security basics page and sign in to your Microsoft account.

    2. Select More security options.

    3. Under App passwords, select Create a new app password. A new app password is generated and appears on your screen.

  3. Use the above generated App Password in the Service suite script instead of your original password

Example code:

Synatx: var mailClient = createMailClient("imap.outlook.com", "test@outlook.com", "App Password" , "IMAP");
 
var mailClient = createMailClient("imap.outlook.com", "test@outlook.com", "goqigersatrcmexc", "IMAP");
 
// Here "goqigersatrcmexc" is an app Password generated for an account.

mailClient.login();
mailClient.setFromFolder("Inbox");
log("Access Inbox");
var lastUnreadMails = mailClient.getLastUnreadMessages(1);
var url = ""
for(var i = 0; i < lastUnreadMails.size(); i++){
//code = lastUnreadMails.get(i);
url = lastUnreadMails.get(i).getSubject();
}
mailClient.logout();
log(url);

Last updated: July 18, 2023

If you have any feedback on this topic, please contact us at documentation@appvance.ai