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:

How to Whitelist GreenTools for G Suite (G4G) For Your Organization How to Whitelist GreenTools for G Suite (G4G) For Your Organization
Posted by November 5, 2023
BVSTools >> BVSTools Software Discussion >> GreenTools for G Suite (Google Apps) (G4G) Specific Discussion
QuickBooks Online Releases QuickBooks Online Releases "New Invoices!"... and It's Terrible!
Posted by October 8, 2023
QuickBooks >> QuickBooks Online
Admin/4i - What is it? Admin/4i - What is it?
Posted by September 30, 2023
Vendor Corner >> MSD Information Technology
BVSTools Releases Send Job Log to BVSTools (SNDLOG2BVS) Command BVSTools Releases Send Job Log to BVSTools (SNDLOG2BVS) Command
Posted by August 28, 2023
BVSTools >> BVSTools Announcements
MAILTOOL Now Allows Email Redirection for Development and Testing MAILTOOL Now Allows Email Redirection for Development and Testing
Posted by May 27, 2023
BVSTools >> BVSTools Announcements >> eMail Tool (MAILTOOL) Specific Announcements
GreenTools for Microsoft Apps (G4MS) Now Supports Footers When Sending Email GreenTools for Microsoft Apps (G4MS) Now Supports Footers When Sending Email
Posted by March 29, 2023
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements
QuickBooks Online - Subtotals and Discounts Frustration QuickBooks Online - Subtotals and Discounts Frustration
Posted by March 16, 2023
QuickBooks >> QuickBooks Online
Making the Switch From QuickBooks Desktop to QuickBooks Online - No Picnic Making the Switch From QuickBooks Desktop to QuickBooks Online - No Picnic
Posted by March 16, 2023
QuickBooks >> QuickBooks Online
BVSTools Software Verified on V7R5 and Power10 BVSTools Software Verified on V7R5 and Power10
Posted by December 9, 2022
BVSTools >> BVSTools Announcements
Microsoft Office 365 Servers and Random Errors Issue Microsoft Office 365 Servers and Random Errors Issue
Posted by November 14, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Sending/Resending Emails Using a MIME File with MAILTOOL Sending/Resending Emails Using a MIME File with MAILTOOL
Posted by November 8, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Sending an HTML Email on Your IBM i Using MAILTOOL Sending an HTML Email on Your IBM i Using MAILTOOL
Posted by November 1, 2022
BVSTools >> BVSTools Software Discussion >> Email Tools (MAILTOOL) Specific Discussion
Transferring License Keys from One System to Another Transferring License Keys from One System to Another
Posted by October 31, 2022
BVSTools >> BVSTools Software Discussion
Calculating the Size of a File Before Base64 Encoding Calculating the Size of a File Before Base64 Encoding
Posted by August 13, 2022
Programming >> RPG Programming
GreenTools for Microsoft Apps (G4MS) v9.12 Now Includes Function to Send Emails using MIME File GreenTools for Microsoft Apps (G4MS) v9.12 Now Includes Function to Send Emails using MIME File
Posted by August 11, 2022
BVSTools >> BVSTools Announcements >> GreenTools for Microsoft Apps (G4MS) Specific Announcements

Reply




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