Skip to main content
13-Aquamarine
July 11, 2023
Solved

In mailserver thing, I need to update/change the configuration by using java script coding.

  • July 11, 2023
  • 1 reply
  • 2766 views

In mailserver thing, I need to update/change the configuration by using java script coding. How to do that?

 

Best answer by Velkumar

Hi @Hariharasuthan 

 

You can use the below service to get the Configuration Table definition and update it

 

The "GetConfigurationTable" service return the existing configuration table as InfoTable

 

You can update this InfoTable with new information and use the "SetConfigurationTable" service to update it

 

Velkumar_0-1689059056399.png

 

/VR

 

1 reply

Velkumar19-TanzaniteAnswer
19-Tanzanite
July 11, 2023

Hi @Hariharasuthan 

 

You can use the below service to get the Configuration Table definition and update it

 

The "GetConfigurationTable" service return the existing configuration table as InfoTable

 

You can update this InfoTable with new information and use the "SetConfigurationTable" service to update it

 

Velkumar_0-1689059056399.png

 

/VR

 

12-Amethyst
July 11, 2023

@Velkumar - I want to add few more information about the query posted by Hariharasuthan.

We have a MailServer thing in which the SMTP configurations have to read and modified as per the user input (we have an equivalent MashUp SMTP screen).

Below is the code so far done

 

var mailServerThing = Things['SMTP-MailServer-Thing'].name;    // MailServer Thing Name

Things['SMTP-MailServer-Thing'].GetConfigurationTable({

// Here, what are all the properties we have to define to read and update the below SMTP parameters

//Parameter 1= Server
//Parameter 2 = Port
//Parameter 3 = Email
//Parameter 4 = Username
//Parameter 5 = Password
//Parameter 6 = SSL
});

 

If we can achieve this, we will be able to get the SMTP values from the Mashup and update them in the MailServer thing SMTP configuration table and send a test email to a test email ID (say aaa@aaa.co.in). If the test email triggered successfully then send a success message to that SMTP mashup screen.

 

@Velkumar - please guide, thank you.

19-Tanzanite
July 11, 2023

Hi @SKannapiran 

 

Please find below code snippet 

 

// Get Configuration value from email server thing
let existingConfiguration = Things["EmailThing"].GetConfigurationTable({
	tableName: "ConnectionInfo" /* STRING */
});

// Update configuration based on User Input
existingConfiguration.smtpServer = Server; 			// SMTP Server
existingConfiguration.smtpPort = PortNumber;		// SMTP Server Port
existingConfiguration.accoundId = Email;			// Mail Account User
existingConfiguration.accountPassword = Password;	// Mail Account Password
existingConfiguration.useSSL = SSL;					// SSL 

// Update Configuration Table
Things["EmailThing"].SetConfigurationTable({
	configurationTable: existingConfiguration /* INFOTABLE */,
	persistent: true /* BOOLEAN {"defaultValue":true} */,
	tableName: "ConnectionInfo" /* STRING */
});

 

/ VR