bvstone

G4MSMAIL Updated to Allow Use Of Configuration Files and More

Posted:

G4MSMAIL Updated to Allow Use Of Configuration Files and More

New Configuration Files

As with MAILTOOL Plus, we have just updated G4MSMAIL so that you are able to use JSON configuration files to set the value of certain options that are static.

When the latest version of G4MS is installed you will get a new file in the IFS named:

/bvstools/g4ms/config/defaults.json

This file will contain all the available parameters that you can use.  Following is an example:

{
	"variables": [
	{
		"name":"id",
		"default":" "
	},
	{
		"name":"from",
		"default":" "
	},
	{
		"name":"from_name",
		"default":" "
	},
	{
		"name":"sender",
		"default":" "
	},
	{
		"name":"sender_name",
		"default":" "
	},
	{
		"name":"subject",
		"default":" "
	},
	{
		"name":"message",
		"default":" "
	}, 
	{
		"name":"message_stream_file",
		"default":" "
	},
	{
		"name":"parent_folder",
		"default":" "
	},
	{
		"name":"label_id",
		"default":" "
	},
	{
		"name":"message_id",
		"default":" "
	},
	{
		"name":"attachment_id",
		"default":" "
	},
	{
		"name":"attachment_name",
		"default":" "
	},
	{
		"name":"get_new_only",
		"default":"*YES"
	},
	{
		"name":"mark_as_read",
		"default":"*YES"
	},
	{
		"name":"move_to_folder",
		"default":" "
	},
	{
		"name":"max_part_size",
		"default":"16773104"
	},
	{
		"name":"get_parts",
		"default":" "
	},
	{
		"name":"message_content_type",
		"default":" "
	},
	{
		"name":"message_importance",
		"default":"Normal"
	},
	{
		"name":"deliver_receipt_requested",
		"default":"false"
	},
	{
		"name":"read_receipt_requested",
		"default":"false"
	},
	{
		"name":"save_to_sent_items",
		"default":"true"
	},
	{
		"name":"no_attachment_action",
		"default":" "
	},
	{
		"name":"temp_dir",
		"default":"/tmp"
	},
	{
		"name":"reset",
		"default":"*YES"
	},
	{
		"name":"ccsid",
		"default":"1208"
	},
	{
		"name":"debug",
		"default":"*NO "
	},
	{
		"name":"debug_file",
		"default":" "
	},
	{
		"name":"dump_file",
		"default":" "
	}	
  ]
}

Any parameters that are specified in the configuration file that is used will override those use previously with the MAILTOOL command.

If you are using the G4MSMAIL subprocedures then the order that you set values and load defaults using the #g4msmail_loadDefaults() function will determine which value is used in the end.

Following is an example program:

     H DFTACTGRP(*NO) ACTGRP('G4MS') BNDDIR('G4MS')
      ****************************************************************
      * Imports
      ****************************************************************
      /COPY QCOPYSRC,P.G4MSMAIL
      ****************************************************************
     D CRLF            C                   CONST(X'0D25')
      *
     D rc              S             10i 0
     D errorMsg        S            256
     D displayErr      S             52
      ****************************************************************
      /free

       rc = #g4msmail_init();
       rc = #g4msmail_setValue('configuration_file':'*DFT');
       rc = #g4msmail_loadDefaults();

       if (rc < 0);
         #g4msmail_dumpSettings(); // This will make a json file with settings and values
       else;
         rc = #g4msmail_addRecipient('bvstone@gmail.com':'Brad@Gmail':g4ms_TO);
         rc = #g4msmail_setValue('subject':'Hello there!');
         rc = #g4msmail_setValue('message':'*STMF');
         rc = #g4msmail_setValue('message_stream_file':'/tmp/test.txt');

         rc = #g4msmail_sendMail(g4ms_uniqueID:errorMsg);

         if (rc < 0);
           #g4msmail_dumpSettings(); // This will make a json file with settings and values
           displayErr = errorMsg;
           DSPLY displayErr;
         endif;

       endif;

       EXSR $return;
       //***************************************************************
       //* Return
       //***************************************************************
       begsr $return;

         *INLR = *ON;
         return;

       endsr;
      /end-free

You will notice that the configuration file is *DFT.  This special value will first look for a configuration file named /bvstools/g4ms/config/<userid>/defaults.json where "<userid>" is the user id of the person running the application.

Instead of *DFT you can also specify the fully qualified path to the configuration file you wish to use.

New Functions

Three new functions are also available with G4MS.

#g4msmail_init() - This is used to initialize everything before running the application.  This isn't required to be used, but it is a good idea to use it if you want all the default values set before you continue with your application.

#g4msmail_loadDefaults() - As mentioned previously, this function is used to set values from a configuration file.  The configuration file is set using the #g4msmail_setValue('configuration_file':<config>') command.

#g4msmail_dumpSettings() - This function is used to dump the settings for your application.  Should G4MSMAIL encounter an error sending the email, this function is automatically called so that along with debug files, the settings used will also be available.


Last edited 01/16/2017 at 16:21:17



Latest Posts:

Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application Why I Cancelled my DynDNS Service and How I Replaced It with an IBM i Application
Posted by 8 hours ago
IBM Power Systems >> (QGPL) IBM i
Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product) Green Tools for G Suite (G4G) Product Updates (Licensing, Functionality, Base Product)
Posted by July 13, 2019
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
Reading JSON Data from Standard Input With YAJL and RPG Reading JSON Data from Standard Input With YAJL and RPG
Posted by July 12, 2019
Programming >> Proof of Concept (POC)
MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications MAILTOOL Updated to Allow Use of IBM Global Security Kit (GSKIT) for SSL/TLS Communications
Posted by June 19, 2019
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI) GETURI v10.00 Released Supporting IBM Global Security Kit (GSKIT) and Server Name Indication (SNI)
Posted by June 11, 2019
BVSTools >> BVSTools Announcements >> Get URI (GETURI) Specific Announcements
BVSTools Now Offers Vertex Cloud Interface BVSTools Now Offers Vertex Cloud Interface
Posted by April 15, 2019
BVSTools >> BVSTools Announcements
Token Has an Invalid Signature Error for Office 365 Email Token Has an Invalid Signature Error for Office 365 Email
Posted by March 22, 2019
BVSTools >> BVSTools Software Discussion >> GreenTools for Microsoft Apps (G4MS) Specific Discussion
Resending Emails that have Errored Out with Updated Router or Authentication Information Resending Emails that have Errored Out with Updated Router or Authentication Information
Posted by March 1, 2019
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i BVSTools Offers Toolset to Work With HubSpot OAuth 2.0 APIs On Your IBM i
Posted by January 27, 2019
BVSTools >> BVSTools Announcements
G4MSDRV Currently Not Supported G4MSDRV Currently Not Supported
Posted by January 17, 2019
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
Removing Trailing Carriage Returns and/or Line Feeds from a String with RPG Removing Trailing Carriage Returns and/or Line Feeds from a String with RPG
Posted by December 26, 2018
Programming >> RPG Programming
Create QRCODE in DDS Create QRCODE in DDS
Posted by September 21, 2018
Programming >> RPG Programming
Base64 Encoding a File with RPG Base64 Encoding a File with RPG
Posted by September 6, 2018
Programming >> RPG Programming
Building JSON with RPG and YAJL and Writing to Standard Output Building JSON with RPG and YAJL and Writing to Standard Output
Posted by August 31, 2018
Programming >> Proof of Concept (POC)
How to Delete Files or Empty Trash From Your Google Drive with your IBM i and RPG/ILE How to Delete Files or Empty Trash From Your Google Drive with your IBM i and RPG/ILE
Posted by July 24, 2018
BVSTools >> BVSTools Software Discussion >> GreenTools for G Suite (Google Apps) (G4G) Specific Discussion

Reply




Copyright 1983-2019 BVSTools
GreenBoard(v3) Powered by the eRPG SDK, MAILTOOL Plus!, GreenTools for Google Apps, jQuery, jQuery UI, BlockUI, CKEditor and running on the IBM i (AKA AS/400, iSeries, System i).