Since: API level 2
public class

EmailAccountPolicy

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.accounts.EmailAccountPolicy

Deprecated in API level 27

Class Overview

This class provides APIs to create and delete e-mail accounts and to control Internet Access Message Protocol (IMAP) or Post Office Protocol (POP) email account-related settings.

Since
API level 2
MDM 2.0

Summary

Constants
String ACCOUNT_TYPE_IMAP Key represents "IMAP" account type
String ACCOUNT_TYPE_POP3 Key represents "POP3" account type
String ACTION_EMAIL_ACCOUNT_ADD_RESULT Broadcast Action: To notify the administrator about account create/update operations status, which is sent after validation of accounts setting.
String ACTION_EMAIL_ACCOUNT_DELETE_RESULT Broadcast Action: To notify the administrator about account delete operations status.
String EXTRA_ACCOUNT_ID The lookup key for long object.
String EXTRA_EMAIL_ADDRESS The lookup key for String object.
String EXTRA_INCOMING_PROTOCOL The lookup key for String object.
String EXTRA_INCOMING_SERVER_ADDRESS The lookup key for String object.
String EXTRA_RESULT The lookup key for integer object.
Public Methods
long addNewAccount(EmailAccount account)
API to add a new email account.
boolean deleteAccount(long accId)
API to delete an email account.
Account getAccountDetails(long accId)
API to get the details of an account based on the account Id.
long getAccountId(String login, String serverAddress, String protocol)
API to obtain an account Id based on the account login, server address, and protocol.
Account[] getAllEmailAccounts()
API to get all email account information as a list.
void removePendingAccount(String emailAddress, String incomingProtocol, String incomingServerAddress)
API to remove account which is still pending creation.
void sendAccountsChangedBroadcast()
API for notifying other applications when email account changes are made.
boolean setAccountName(String accountName, long accId)
API to change the account name displayed for the email account.
boolean setAlwaysVibrateOnEmailNotification(boolean enable, long accId)
API to enable or disable the email account setting 'Always Vibrate On Email Notification'.
boolean setAsDefaultAccount(long accId)
API to set a given account as the default.
boolean setInComingProtocol(String protocol, long accId)
API to set email account incoming protocol.
boolean setInComingServerAcceptAllCertificates(boolean acceptAllCertificates, long accId)
API to enable or disable Secure Sockets Layer (SSL) accepting all certificates for incoming connections.
long setInComingServerAddress(String serverAddress, long accId)
API to set the incoming server address.
boolean setInComingServerPassword(String password, long accId)
API to change the incoming server password.
boolean setInComingServerPort(int port, long accId)
API to set the incoming server port number.
boolean setInComingServerSSL(boolean enableSSL, long accId)
API to enable or disable the email account setting for incoming server Secure Sockets Layer (SSL).
boolean setOutGoingServerAcceptAllCertificates(boolean acceptAllCertificates, long accId)
API to enable or disable the outgoing server accepting all certificates.
long setOutGoingServerAddress(String serverAddress, long accId)
API to set the outgoing server address.
boolean setOutGoingServerPassword(String password, long accId)
API to change the outgoing server password.
boolean setOutGoingServerPort(int port, long accId)
API to set the outgoing port number.
boolean setOutGoingServerSSL(boolean enableSSL, long accId)
API to enable or disable Secure Sockets Layer (SSL) on the outgoing email server account.
boolean setSenderName(String senderName, long accId)
API to change the sender name of the email account.
boolean setSignature(String signature, long accId)
API to change the signature in the the email account.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACCOUNT_TYPE_IMAP

Since: API level 6

Key represents "IMAP" account type

Since
API level 6
MDM 4.0
Constant Value: "imap"

public static final String ACCOUNT_TYPE_POP3

Since: API level 6

Key represents "POP3" account type

Since
API level 6
MDM 4.0
Constant Value: "pop3"

public static final String ACTION_EMAIL_ACCOUNT_ADD_RESULT

Since: API level 6

Broadcast Action: To notify the administrator about account create/update operations status, which is sent after validation of accounts setting. This intent can be sent several times for one account; an example is when Settings validation failed because the user initially entered the wrong password and later retried by entering the correct value.

The intent has the following extra values:

EXTRA_RESULT

EXTRA_INCOMING_PROTOCOL

EXTRA_EMAIL_ADDRESS

EXTRA_INCOMING_SERVER_ADDRESS

EXTRA_ACCOUNT_ID

Permission
The use of this intent requires the user to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.action.EMAIL_ACCOUNT_ADD_RESULT"

public static final String ACTION_EMAIL_ACCOUNT_DELETE_RESULT

Since: API level 6

Broadcast Action: To notify the administrator about account delete operations status.

The intent has the following extra values:

EXTRA_RESULT

EXTRA_INCOMING_PROTOCOL

EXTRA_EMAIL_ADDRESS

EXTRA_INCOMING_SERVER_ADDRESS

EXTRA_ACCOUNT_ID

Permission
The use of this intent requires the user to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.action.EMAIL_ACCOUNT_DELETE_RESULT"

public static final String EXTRA_ACCOUNT_ID

Since: API level 6

The lookup key for long object. Retrieve with getLongExtra(String, long). Account Id in email database or -1 in case of account creation, account update, and deletion of nonvalidating accounts.

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.ACCOUNT_ID"

public static final String EXTRA_EMAIL_ADDRESS

Since: API level 6

The lookup key for String object. Retrieve with getStringExtra(String). Account email address used to identify account

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.EMAIL_ADDRESS"

public static final String EXTRA_INCOMING_PROTOCOL

Since: API level 6

The lookup key for String object. Retrieve with getStringExtra(String). Account protocol "pop3" or "imap" used to identify account type.

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.INCOMING_PROTOCOL"

public static final String EXTRA_INCOMING_SERVER_ADDRESS

Since: API level 6

The lookup key for String object. Retrieve with getStringExtra(String). Account incoming server host address used to identify account

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.INCOMING_SERVER_ADDRESS"

public static final String EXTRA_RESULT

Since: API level 6

The lookup key for integer object. Retrieve with getIntExtra(String, int). Status for account creation/update/delete

  • Value 0 - Success
  • Value 1 - Activation error for setup result intent or fail due to delete result intent
  • Value 2 - Authentication error
  • Value 3 - IO error
  • Value 7 - Error when saving account to database
  • Value 8 - Other errors

Since
API level 6
MDM 4.0
Constant Value: "com.samsung.android.knox.intent.extra.RESULT"

Public Methods

public long addNewAccount (EmailAccount account)

Since: API level 11

API to add a new email account.

Parameters
account EmailAccount class for email account
Returns
  • On success, valid account Id if Android version is less than 4.0 else 0 for Android version 4.0 onwards. On failure, -1.
Throws
SecurityException If caller does not have required permissions
Usage

An administrator can use this API to remotely configure an email account on the user's device without user interaction. A user can change most of these settings.

The administrator can register ACTION_EMAIL_ACCOUNT_ADD_RESULT intent to receive account creation status and create account's Id.

The administrator can use removePendingAccount(String, String, String) to delete nonvalidated pending accounts.

NOTE:

On For Android version 4.0 onward, an account is not added until the user/administrator launches the email application. After launch, the email application processes account creation and is ready to use, retrieve information, and update.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

  try {

          accountId = emailAccountPolicy.addNewAccount(new EmailAccount(

             "testemail@gmail.com","pop3","pop.gmail.com", 995,

             "testemail@gmail.com", null,"smtp", "smtp.gmail.com",465,

             "testemail@gmail.com",null));



          if(accountId >= 0){

              Log.d(TAG," Adding a new email account has succeeded!");

              // Administrator needs to call sendAccountsChangedBroadcast() API

              // to notify regarding email account addition.

              emailAccountPolicy.sendAccountsChangedBroadcast();



          }else{

              Log.d(TAG," Adding a new email account failed.");

          }

  } catch(SecurityException e) {

      Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

  try {

          accountId = emailAccountPolicy.addNewAccount(new EmailAccount(

             "testemail@gmail.com","pop3","pop.gmail.com", 995,

             "testemail@gmail.com", null,"smtp", "smtp.gmail.com",465,

             "testemail@gmail.com",null));



          if(accountId >= 0){

              Log.d(TAG," Adding a new email account has succeeded!");

              // Administrator needs to call sendAccountsChangedBroadcast() API

              // to notify regarding email account addition.

              emailAccountPolicy.sendAccountsChangedBroadcast();



          }else{

              Log.d(TAG," Adding a new email account failed.");

          }

  } catch(SecurityException e) {

      Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 11
MDM 5.0
Multiuser Environment
User Scope

public boolean deleteAccount (long accId)

Since: API level 2

API to delete an email account.

Parameters
accId Id of account to be deleted
Returns
  • true if the account successfully deleted, else returns false
Throws
SecurityException If caller does not have required permissions
Usage

An administrator can use this API to remotely delete an email account and all related data. The key to using this API is the enterprise account Id, which is obtained using getAccountId(String, String, String). Account deletion occurs without user interaction.

The administrator can register ACTION_EMAIL_ACCOUNT_DELETE_RESULT intent to receive account deletion status.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result = emailAccountPolicy.deleteAccount(accountId);

          if(result){

              Log.d(TAG," Deleting account succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account deletion.

              mEmailAccountPolicy.sendAccountsChangedBroadcast();



          }else{

              Log.d(TAG," Deleting account failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result = emailAccountPolicy.deleteAccount(accountId);

          if(result){

              Log.d(TAG," Deleting account succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account deletion.

              mEmailAccountPolicy.sendAccountsChangedBroadcast();



          }else{

              Log.d(TAG," Deleting account failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public Account getAccountDetails (long accId)

Since: API level 2

API to get the details of an account based on the account Id.

Parameters
accId Id of the account containing the details to be queried
Returns
  • Account object filled with all account details.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this utility API to obtain the account details of a particular email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String).


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          Account account =   emailAccountPolicy.getAccountDetails(accountId);

          if(account != null){

              Log.d(TAG," Getting account details succeeded!");

          }else{

              Log.d(TAG," Getting account details failed/null.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          Account account =   emailAccountPolicy.getAccountDetails(accountId);

          if(account != null){

              Log.d(TAG," Getting account details succeeded!");

          }else{

              Log.d(TAG," Getting account details failed/null.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public long getAccountId (String login, String serverAddress, String protocol)

Since: API level 2

API to obtain an account Id based on the account login, server address, and protocol.

Parameters
login Incoming or outgoing username/login
serverAddress Incoming or outgoing server address
protocol Incoming or outgoing server protocol ("pop3" or "imap")
Returns
  • Account Id that has the unique combination of login, protocol, and server address on success, else -1
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this utility API to obtain the account Id of a particular email account. Any email account is uniquely represented by a combination of the login, server address, and protocol. All parameters for this API are case sensitive.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          long  accountId = emailAccountPolicy.getAccountId(

                         "testemail@gmail.com","pop.gmail.com","pop3");

          if(accountId >0){

              Log.d(TAG," Get account Id is valid!");



          }else{

              Log.d(TAG," Get account Id is invalid.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          long  accountId = emailAccountPolicy.getAccountId(

                         "testemail@gmail.com","pop.gmail.com","pop3");

          if(accountId >0){

              Log.d(TAG," Get account Id is valid!");



          }else{

              Log.d(TAG," Get account Id is invalid.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public Account[] getAllEmailAccounts ()

Since: API level 2

API to get all email account information as a list.

Returns
  • Account object array filled with all account details if any email accounts exist else account object is null
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to get all existing email accounts on the device.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

         Account[] account = emailAccountPolicy.getAllEmailAccounts();



         if(account! =null){

              Log.d(TAG," Return email accounts information succeeded!");



         }else{

          Log.d(TAG," Return email accounts information failed/null.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

         Account[] account = emailAccountPolicy.getAllEmailAccounts();



         if(account! =null){

              Log.d(TAG," Return email accounts information succeeded!");



         }else{

          Log.d(TAG," Return email accounts information failed/null.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public void removePendingAccount (String emailAddress, String incomingProtocol, String incomingServerAddress)

Since: API level 2

API to remove account which is still pending creation.

Parameters
emailAddress Email Address of the account.
incomingProtocol Incoming server protocol ("pop3" or "imap")
incomingServerAddress Incoming server address
Throws
SecurityException If caller does not have required permissions
Usage
Administrator can use this API to remove pending email account from the device.


       EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

       EmailAccountPolicy emailAccountPolicy = edm.getEmailAccountPolicy();

       try {

           emailAccountPolicy.removePendingAccount("testemail@gmail.com", "pop3", "pop.gmail.com");

       } catch (SecurityException e) {

           Log.w(TAG, "SecurityException: " + e);

       }

       
For Container:

       // When you create container successfully, containerID will be returned via intent.

       // Use this containerID in below API.

       EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

       KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

       EmailAccountPolicy emailAccountPolicy = kcm.getEmailAccountPolicy();

       try {

           emailAccountPolicy.removePendingAccount("testemail@gmail.com", "pop3", "pop.gmail.com");

       } catch (SecurityException e) {

           Log.w(TAG, "SecurityException: " + e);

       }

       
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public void sendAccountsChangedBroadcast ()

Since: API level 2

API for notifying other applications when email account changes are made.

Throws
SecurityException If caller does not have required permissions
Usage
This API enables all other applications that depend on the email account to be informed if any changes are made to account parameters.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result = emailAccountPolicy.deleteAccount(mAccountId);

          if(result){

              Log.d(TAG," Add/change/update to account succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account deletion.

          emailAccountPolicy.sendAccountsChangedBroadcast();



          }else{

              Log.d(TAG," Add/change/update to account failed.");

          }



 } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result = emailAccountPolicy.deleteAccount(mAccountId);

          if(result){

              Log.d(TAG," Add/change/update to account succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account deletion.

          emailAccountPolicy.sendAccountsChangedBroadcast();



          }else{

              Log.d(TAG," Add/change/update to account failed.");

          }



 } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setAccountName (String accountName, long accId)

Since: API level 2

API to change the account name displayed for the email account.

Parameters
accountName Account name String
accId Id of account to be changed
Returns
  • true if successful, false false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the user-readable name associated with an email account. The key to using this API is the enterprise account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setAccountName(

                          "testEmailAccountName", accountId);

          if(result){

              Log.d(TAG," Setting account name succeeded!");



              // Admin/User need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," Setting account name failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setAccountName(

                          "testEmailAccountName", accountId);

          if(result){

              Log.d(TAG," Setting account name succeeded!");



              // Admin/User need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," Setting account name failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setAlwaysVibrateOnEmailNotification (boolean enable, long accId)

Since: API level 2

API to enable or disable the email account setting 'Always Vibrate On Email Notification'.

Parameters
enable true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether the device always vibrates when a new email is received. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result= emailAccountPolicy.setAlwaysVibrateOnEmailNotification

                     (true, accountId);

          if(result){

              Log.d(TAG," setAlwaysVibrateOnEmailNotification succeeded!");

              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG,"setAlwaysVibrateOnEmailNotification failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result= emailAccountPolicy.setAlwaysVibrateOnEmailNotification

                     (true, accountId);

          if(result){

              Log.d(TAG," setAlwaysVibrateOnEmailNotification succeeded!");

              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG,"setAlwaysVibrateOnEmailNotification failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setAsDefaultAccount (long accId)

Since: API level 2

API to set a given account as the default.

Parameters
accId Id of account to be set as default
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to set a particular account as the default account. The key to using this API is the enterprise account Id which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setAsDefaultAccount(accountId);

          if(result){

              Log.d(TAG,"setAsDefaultAccount succeeded!");



          }else{

              Log.d(TAG," setAsDefaultAccount failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setAsDefaultAccount(accountId);

          if(result){

              Log.d(TAG,"setAsDefaultAccount succeeded!");



          }else{

              Log.d(TAG," setAsDefaultAccount failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setInComingProtocol (String protocol, long accId)

Since: API level 2

API to set email account incoming protocol.

Parameters
protocol Protocol as String Example: pop3 or imap
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the incoming protocol of the email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setInComingProtocol("pop3",

                         accountId);

          if(result){

              Log.d(TAG," setInComingProtocol succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setInComingProtocol failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setInComingProtocol("pop3",

                         accountId);

          if(result){

              Log.d(TAG," setInComingProtocol succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setInComingProtocol failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setInComingServerAcceptAllCertificates (boolean acceptAllCertificates, long accId)

Since: API level 2

API to enable or disable Secure Sockets Layer (SSL) accepting all certificates for incoming connections.

Parameters
acceptAllCertificates true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether SSL accepts all certificates for incoming connections of an email account. The key to using this API is the enterprise account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result=emailAccountPolicy.

             setInComingServerAcceptAllCertificates(true, accountId);

          if(result){

              Log.d(TAG,"setInComingServerAcceptAllCertificates succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

               emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG,"setInComingServerAcceptAllCertificates failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result=emailAccountPolicy.

             setInComingServerAcceptAllCertificates(true, accountId);

          if(result){

              Log.d(TAG,"setInComingServerAcceptAllCertificates succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

               emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG,"setInComingServerAcceptAllCertificates failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public long setInComingServerAddress (String serverAddress, long accId)

Since: API level 2

API to set the incoming server address.

Parameters
serverAddress Incoming server address
accId Id of account to be changed
Returns
  • valid account id if successful, else -1.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the incoming server address of the email account. The key to using this API is the managed email account Id, which is obtained using getAccountId(String, String, String). The user can change this parameter.

NOTE: The account Id changes if this API call succeeds.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          long mNewAccId =   emailAccountPolicy.setInComingServerAddress(

                         "pop.gmail.com", accountId);

          if(mNewAccId >0){

              Log.d(TAG," setInComingServerAddress succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              // if the base parameter of existing email account changes,the existing

              // email account id will be deleted and a new email account will be

              // created with different account id.

              emailAccountPolicy.sendAccountsChangedBroadcast();

            }else{

              Log.d(TAG," setInComingServerAddress failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          long mNewAccId =   emailAccountPolicy.setInComingServerAddress(

                         "pop.gmail.com", accountId);

          if(mNewAccId >0){

              Log.d(TAG," setInComingServerAddress succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              // if the base parameter of existing email account changes,the existing

              // email account id will be deleted and a new email account will be

              // created with different account id.

              emailAccountPolicy.sendAccountsChangedBroadcast();

            }else{

              Log.d(TAG," setInComingServerAddress failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setInComingServerPassword (String password, long accId)

Since: API level 2

API to change the incoming server password.

Parameters
password Password String
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the incoming server password of the email account. The key to use this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setInComingServerPassword

                         ("password123", accountId);

          if(result){

              Log.d(TAG,"setInComingServerPassword succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

           }else{

              Log.d(TAG," setInComingServerPassword failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setInComingServerPassword

                         ("password123", accountId);

          if(result){

              Log.d(TAG,"setInComingServerPassword succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

           }else{

              Log.d(TAG," setInComingServerPassword failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setInComingServerPort (int port, long accId)

Since: API level 2

API to set the incoming server port number.

Parameters
port Port number
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the incoming server port for the email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setInComingServerPort(995,

                          accountId);

          if(result){

              Log.d(TAG," setInComingServerPort succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG,"setInComingServerPort failed.");

          }

  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setInComingServerPort(995,

                          accountId);

          if(result){

              Log.d(TAG," setInComingServerPort succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG,"setInComingServerPort failed.");

          }

  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setInComingServerSSL (boolean enableSSL, long accId)

Since: API level 2

API to enable or disable the email account setting for incoming server Secure Sockets Layer (SSL).

Parameters
enableSSL true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether SSL should be used for incoming connections of the email account. The key to use this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result =   emailAccountPolicy.setInComingServerSSL(true,

                          accountId);

          if(result){

              Log.d(TAG," setInComingServerSSL succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setInComingServerSSL failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result =   emailAccountPolicy.setInComingServerSSL(true,

                          accountId);

          if(result){

              Log.d(TAG," setInComingServerSSL succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setInComingServerSSL failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setOutGoingServerAcceptAllCertificates (boolean acceptAllCertificates, long accId)

Since: API level 2

API to enable or disable the outgoing server accepting all certificates.

Parameters
acceptAllCertificates true to enable, false to disable
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether Secure Sockets Layer (SSL) accepts all certificates for outgoing connections of the email account. The key to using this API is the enterprise account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result=emailAccountPolicy.

                 setOutGoingServerAcceptAllCertificates(true, accountId);

          if(result){

              Log.d(TAG," setOutGoingServerAcceptAllCertificates succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerAcceptAllCertificates failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");



          boolean result=emailAccountPolicy.

                 setOutGoingServerAcceptAllCertificates(true, accountId);

          if(result){

              Log.d(TAG," setOutGoingServerAcceptAllCertificates succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerAcceptAllCertificates failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public long setOutGoingServerAddress (String serverAddress, long accId)

Since: API level 2

API to set the outgoing server address.

Parameters
serverAddress Server address
accId Id of account to be changed
Returns
  • Valid account id if successful, else -1.
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the outgoing server address of the email account. The key to using this API is the managed email account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.

NOTE: The account Id changes if this API call succeeds.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          long newAccId =   emailAccountPolicy.setOutGoingServerAddress(

                         "smtp.gmail.com", accountId);

          if(newAccId >0){

              Log.d(TAG," setOutGoingServerAddress succeeded!");



              // Administrator needs to call sendAccountsChangedBroadcast() API

              // to notify about the  email account changes.

              // if the base parameter of existing email account changes, the existing

              // email account Id is deleted and a new email account is

              // created with a different account Id.



              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerAddress failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          long newAccId =   emailAccountPolicy.setOutGoingServerAddress(

                         "smtp.gmail.com", accountId);

          if(newAccId >0){

              Log.d(TAG," setOutGoingServerAddress succeeded!");



              // Administrator needs to call sendAccountsChangedBroadcast() API

              // to notify about the  email account changes.

              // if the base parameter of existing email account changes, the existing

              // email account Id is deleted and a new email account is

              // created with a different account Id.



              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerAddress failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setOutGoingServerPassword (String password, long accId)

Since: API level 2

API to change the outgoing server password.

Parameters
password Password String
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the outgoing password of the email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setOutGoingServerPassword

                         ("password123",accountId);

          if(result){

              Log.d(TAG," setOutGoingServerPassword succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

               emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerPassword failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setOutGoingServerPassword

                         ("password123",accountId);

          if(result){

              Log.d(TAG," setOutGoingServerPassword succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

               emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerPassword failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setOutGoingServerPort (int port, long accId)

Since: API level 2

API to set the outgoing port number.

Parameters
port Port number
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the outgoing server port of the email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setOutGoingServerPort(465,

                          accountId);

          if(result){

              Log.d(TAG," setOutGoingServerPort succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerPort failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId = emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setOutGoingServerPort(465,

                          accountId);

          if(result){

              Log.d(TAG," setOutGoingServerPort succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerPort failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setOutGoingServerSSL (boolean enableSSL, long accId)

Since: API level 2

API to enable or disable Secure Sockets Layer (SSL) on the outgoing email server account.

Parameters
enableSSL true to enable, false to disable
accId Id of the account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure whether SSL is used for outgoing connections of the email account. The key to using this API is the enterprise account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setOutGoingServerSSL(true,

                      accountId);

          if(result){

              Log.d(TAG," setOutGoingServerSSL succeeded!");



              // Admin/User need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerSSL failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }



  
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setOutGoingServerSSL(true,

                      accountId);

          if(result){

              Log.d(TAG," setOutGoingServerSSL succeeded!");



              // Admin/User need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," setOutGoingServerSSL failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }



 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setSenderName (String senderName, long accId)

Since: API level 2

API to change the sender name of the email account.

Parameters
senderName Sender name String
accId Id of account to be changed
Returns
  • true if successful, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the sender name of the email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result = emailAccountPolicy.setSenderName("test", accountId);

          if(result){

              Log.d(TAG," Setting sender name succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," Setting sender name failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result = emailAccountPolicy.setSenderName("test", accountId);

          if(result){

              Log.d(TAG," Setting sender name succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

          }else{

              Log.d(TAG," Setting sender name failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope

public boolean setSignature (String signature, long accId)

Since: API level 2

API to change the signature in the the email account.

Parameters
signature Signature String
accId Id of the account to be changed
Returns
  • true if success, else false
Throws
SecurityException If caller does not have required permissions
Usage
An administrator can use this API to remotely configure the signature of the email account. The key to using this API is the managed account Id, which is obtained using getAccountId(String, String, String). A user can change this parameter.


 long  accountId = -1;

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);

 EmailAccountPolicy  emailAccountPolicy = edm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setSignature(

                         "MyTestSignature", accountId);

          if(result){

              Log.d(TAG," Setting signature succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

           }else{

              Log.d(TAG," Setting signature failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
For Container:

 long  accountId = -1;

 // When you create container successfully, containerID will be returned via intent.

 // Use this containerID in below API.

 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);

 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);

 EmailAccountPolicy  emailAccountPolicy = kcm.getEmailAccountPolicy();

 try {

          accountId =   emailAccountPolicy.getAccountId("testemail@gmail.com",

                      "pop.gmail.com","pop3");

          boolean result =   emailAccountPolicy.setSignature(

                         "MyTestSignature", accountId);

          if(result){

              Log.d(TAG," Setting signature succeeded!");



              // Administrator need to call sendAccountsChangedBroadcast() API

              // to notify the  email account changes.

              emailAccountPolicy.sendAccountsChangedBroadcast();

           }else{

              Log.d(TAG," Setting signature failed.");

          }



  } catch(SecurityException e) {

       Log.w(TAG,"SecurityException: "+e);

  }

 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_EMAIL" permission which has a protection level of signature.
Since
API level 2
MDM 2.0
Multiuser Environment
User Scope