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:

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
GreenTools for G Suite (G4G) Updated to Include Delete and Empty Trash Function GreenTools for G Suite (G4G) Updated to Include Delete and Empty Trash Function
Posted by July 24, 2018
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
What to Do If Your License Keys Don't Work What to Do If Your License Keys Don't Work
Posted by July 18, 2018
BVSTools >> BVSTools Software Discussion
MAILTOOL Updated to Allow Failed Message on Invalid Recipient MAILTOOL Updated to Allow Failed Message on Invalid Recipient
Posted by May 20, 2018
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
Non HTTPS Callbacks Removed from GreenTools for G Suite (G4G) Non HTTPS Callbacks Removed from GreenTools for G Suite (G4G)
Posted by April 15, 2018
BVSTools >> BVSTools Announcements >> GreenTools for G Suite (Google Apps) (G4G) Specific Announcements
IBM i Related Survey Available IBM i Related Survey Available
Posted by April 7, 2018
IBM Power Systems >> (QGPL) IBM i
BVSTools Releases Braintree Webhook Open Source Application - Node.js BVSTools Releases Braintree Webhook Open Source Application - Node.js
Posted by April 5, 2018
Programming >> Open Source
BVSTools Now Offering Web Services (BETA) BVSTools Now Offering Web Services (BETA)
Posted by April 3, 2018
BVSTools >> BVSTools Announcements
Creating a Reverse SSL Proxy Using RPG on the IBM i - Part 2 Creating a Reverse SSL Proxy Using RPG on the IBM i - Part 2
Posted by March 29, 2018
Programming >> Web Programming
Still on V7R1 or Earlier?  Here's Why You Should Upgrade NOW! Still on V7R1 or Earlier? Here's Why You Should Upgrade NOW!
Posted by February 21, 2018
IBM Power Systems >> (QGPL) IBM i
Converting a MMDDYY date format to YYMMDD for Sorting Using SQL Converting a MMDDYY date format to YYMMDD for Sorting Using SQL
Posted by February 16, 2018
Programming >> RPG Programming
Moving All Files from a Google Drive Folder to the Trash Using GreenTools for Google Apps (G4G) Moving All Files from a Google Drive Folder to the Trash Using GreenTools for Google Apps (G4G)
Posted by February 3, 2018
BVSTools >> BVSTools Software Discussion >> GreenTools for G Suite (Google Apps) (G4G) Specific Discussion

Reply




Copyright 1983-2018 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).