Author Topic: Print to Email.....sort of...  (Read 14526 times)

Per E. Johannessen

  • Sr. Member
  • ****
  • Posts: 256
  • Karma: +3/-0
    • View Profile
Print to Email.....sort of...
« on: October 15, 2014, 04:01:26 pm »
Does anyone know about a utility that can do the following:

Select pdf-files from a folder and automatically mail them as attachments.
The files are in the format CLIENT12345INVOICE67890.PDF so it has to select based on the client no. and look up the email address for this client in a table or something.
Then move the files that are mailed to one folder, and those not sent to another since not all clients have an email registered.

Something like Zan Image Printer that can extract the address from the file would be even better.
http://www.zan1011.com/

Any ideas, except telling me to learn REXX ?

Doug Bissett

  • Hero Member
  • *****
  • Posts: 1604
  • Karma: +4/-2
    • View Profile
Re: Print to Email.....sort of...
« Reply #1 on: October 22, 2014, 09:14:50 pm »
Quote
Any ideas, except telling me to learn REXX ?

It would seem that that is the final answer to your problem.

PMMail has a utility PMMSEND which will send the messages, but you need some sort of program to tell it what to send. REXX is probably the easiest for non programmers.

guzzi

  • Sr. Member
  • ****
  • Posts: 331
  • Karma: +0/-0
    • View Profile
Re: Print to Email.....sort of...
« Reply #2 on: October 23, 2014, 08:48:55 pm »
REXXmail has some features that could be used for this, but you'd still have to learn REXX to make it work...There are some people here who could probably help you with a script that would do what you want.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 284
  • Karma: +5/-0
    • View Profile
Re: Print to Email.....sort of...
« Reply #3 on: October 24, 2014, 08:49:37 am »
You should use some REXX script to do what you want. We can perhaps post our partial solutions (functions) here to each task that has to be handled to create the e-mail(s).



Can we assume that the file ( clients.txt ) look like?
12345{TAB}John Doe{TAB}john.doe@gmail.com
67890{TAB}Jane Doe{TAB}jane.doe@gmail.com
13579{TAB}Joe Doe{TAB}joe.doe@gmail.com
24680{TAB}Jill Doe{TAB}jill.doe@gmail.com

Let's begin with some of the code for you all to add your suggestions to.
Code: [Select]
/* Script to send PDF-files to clients */
path = 'C:\invoices'
client_email = 'C:\invoices\clients.txt'

/* Load RexxUtil Library */
IF RxFuncQuery( 'SysLoadFuncs' ) THEN
DO
    CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    CALL SysLoadFuncs
END

/* Find the files to send */
IF( SysFileTree( path'\CLIENT*.PDF', 'filename.', 'FO' ) THEN
DO i = 1 TO filename.0 /* Go through each found filename */
  PARSE UPPER VALUE filename.i WITH 'CLIENT'clientno'INVOICE'invoiceno'.'extension

  /* Find the email address based on client number (clientno) */
  /* ... add the call to function here (instead of this comment) ... */

  /* Create the e-mail with PMMSend */
  /* ... add the call to function here (instead of this comment) ... */
END
RETURN rc

/* Find the email address based on client number (clientno) */
/* ... and write the actual function here (instead of this comment) ... */

/* Create the e-mail with PMMSend */
/* ... and write the actual function here (instead of this comment) ... */


Per E. Johannessen

  • Sr. Member
  • ****
  • Posts: 256
  • Karma: +3/-0
    • View Profile
Re: Print to Email.....sort of...
« Reply #4 on: October 25, 2014, 03:23:13 pm »
Thanks, Jan-Erik, but I've found someone to write the script for me.
Perhaps others also find this interesting so more functions to the script would be fine.