Forums >> Programming >> Proof of Concept (POC)
Creating Random Email Signatures with GMail
by: bvstone

Jump to: 






bvstone

Creating Random Email Signatures with GMail

Posted:
Creating Random Email Signatures with GMail

I remember years ago, before the use of a web client for email, that we had scripts that would let us insert a random quote to the signature of each email we sent out.  I personally had a ball with this as I was a huge Seinfeld fan, so finding a list of funny Seinfeld quotes was the hard part, but once I had the list of quotes, each email I sent I hoped would instilled a little smile, no matter the topic.

I had the same question when it came to the GMail web client.  I found a Chrome add on named Signature Wizard that looked like it might do the trick, and it did!

Signature Wizard allows you to specify a URL (which is required to be SSL or https) to the location of your signature.  So what it does is grab the contents of that URL (as if it were a web page) and insert it into the bottom of the email.

Well, in my case I created an eRPG (CGI) program as my URL.  I filled a folder up with quotes (in this case, reasons why MAILTOOL is awesome) and tested away.

The setup/options screen for Signature Wizard is very straightforward and easy to use:

Once I got this set up, I tried it out.  But nothing worked.  That's because I forgot you should stop and restart Chrome for the addon to take affect.  Not the first time I've forgotten that!

But, once it was done, things were working great!  Each email now would have a random quote inserted into it.  Random because of the eRPG program (or CGI script) that I was using was in itself generating which template file to use and to output when it is called.

The program is very simple, and looks like this:

H DFTACTGRP(*NO) BNDDIR('ERPGSDK')                                                   
 ****************************************************************                    
 * Prototypes                                                   *                    
 ****************************************************************                    
 /COPY QCOPYSRC,P.ERPGSDK                                                            
 ****************************************************************                    
D randNum         S             10i 0                                                
D numSigs         S             10i 0  INZ(23)                                       
 ****************************************************************                    
 /free                                                                               
  #startup();                                                                        
  #writeTemplate('stdhtmlheader.erpg');                                              
  
  exec sql                                                                           
    set :randNum = RAND() * :numSigs;                                                
                                                                                     
  #writeTemplate('signatures/sig' + %char(randNum) + '.html');                       
  #cleanup();                                                                        
  *INLR = *ON;  
/end-free                                                                                          

First, we use the eRPG SDK to write out standard HTTP headers.  Next, we use the SQL RAND() function to generate a random number.  We multiply that number times the number of signatures (numbered from 0 to 22) so that the number is an integer between 0 and 22.  We use that number to create the path to the signature we want to add.  

Now, we open a new message, or reply to an existing message and the quote is added automatically for us.  

I did find that it really didn't get added until I clicked on the message window, or the send button.  But it does indeed work rather nicely!

Very simple and effective!


Last edited 06/27/2017 at 15:08:01




Reply




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