dbTalk Databases Forums  

Sending w-mail with attachments via *nix

comp.databases.pick comp.databases.pick


Discuss Sending w-mail with attachments via *nix in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
dgraham@storis.com
 
Posts: n/a

Default Sending w-mail with attachments via *nix - 10-10-2006 , 12:59 PM






I know this has been asked and answered several times before but I
can't seem to tease the information out of the net...

I want to send an e-mail via "mail", "Mail" or "sendmail" in *nix and I
want to include an attachments. Can someone give me a clue as to how
to do that from within PICK/U2?

Thanks in advance,

Dave


Reply With Quote
  #2  
Old   
Jeffrey Kaufman
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-10-2006 , 02:57 PM






Here is a code snip from one of my programs. Of course you need to set your
own variables. I hope this helps. I'm sure there are more elegant ways to do
this. But it works.

(FREC is the flat file)


*
* EMAIL INVOICE
*
EMAIL.INV:
*
OPEN 'MD' TO MD ELSE
ERR.REC<1,-1>='CANNOT OPEN FILE "MD" '
RETURN
END
AM=CHAR(254)
WRITE "q":AM:AM:"unix:/tmp" ON MD, "UNIX.TMP.FILE"
OPEN 'UNIX.TMP.FILE' TO UNIX.TMP.FILE ELSE
ERR.REC<1,1>='CANNOT OPEN FILE "UNIX.TMP.FILE (/tmp)" '
RETURN
END
*
READ TO.EMAILS FROM FILES(1),"PS.EMAIL.LIST.INV" ELSE
TO.EMAILS=DEFAULT.EMAIL
END
FROM.EMAIL=KPRMS(93)<111>
IF FROM.EMAIL="" THEN FROM.EMAIL=DEFAULT.EMAIL
KEYID = DATE():TIME():RND(9000)
TEXT.MSG=COMPANY.NAME:' Invoice for ':OCONV(DATE(),"D/")
BOUNDARY="unique-boundary"
SUBJECT='Invoice Attached ':REC.NO
MSG=''
MSG = MSG:"Date: ":OCONV(DATE(),"D4"):"
":OCONV(TIME(),'MT'):CHAR(13):CHAR(10)
MSG = MSG:"From: ":FROM.EMAIL:CHAR(13):CHAR(10)
MSG = MSG:"MIME-Version: 1.0":CHAR(13):CHAR(10)
MSG = MSG: "To: ":TO.EMAILS<1>:CHAR(13):CHAR(10)
J=DCOUNT(TO.EMAILS,CHAR(254))
FOR I=2 TO J
MSG = MSG: "CC: ":TO.EMAILS<I>:CHAR(13):CHAR(10)
NEXT I
MSG = MSG:"Subject: ":SUBJECT:CHAR(13):CHAR(10)
MSG = MSG:"Content-type: multipart/mixed; "
MSG = MSG:'boundary="':BOUNDARY:'";':CHAR(13):CHAR(10)
BOUNDARY="--":BOUNDARY
MSG = MSG:CHAR(13):CHAR(10)
MSG = MSG:BOUNDARY:CHAR(13):CHAR(10)
MSG = MSG:"Content-type: text/plain; charset=us-ascii":CHAR(13):CHAR(10)
MSG = MSG:"Content-type: multipart/mixed; "
MSG = MSG:'boundary="':BOUNDARY:'";':CHAR(13):CHAR(10)
BOUNDARY="--":BOUNDARY
MSG = MSG:CHAR(13):CHAR(10)
MSG = MSG:BOUNDARY:CHAR(13):CHAR(10)
MSG = MSG:"Content-type: text/plain; charset=us-ascii":CHAR(13):CHAR(10)
MSG = MSG:"Content-Transfer-Encoding: 7bit":CHAR(13):CHAR(10)
MSG = MSG:"Content-Disposition: inline":CHAR(13):CHAR(10)
MSG = MSG:CHAR(13):CHAR(10)
MSG = MSG:TEXT.MSG:CHAR(13):CHAR(10)
MSG = MSG:CHAR(13):CHAR(10)
*
* ATTACHMENT
*
MSG = MSG:BOUNDARY:CHAR(13):CHAR(10)
MSG = MSG:"Content-type: text/plain;charset=us-ascii":CHAR(13):CHAR(10)
MSG = MSG:"Content-Transfer-Encoding: 7bit":CHAR(13):CHAR(10)
MSG = MSG:'Content-Disposition:
attachment;filename="':REC.NO:'"':CHAR(13):CHAR(10 )
MSG = MSG:CHAR(13):CHAR(10)
J=DCOUNT(FREC,CHAR(254))
FOR I=1 TO J
MSG=MSG:FREC<I>:CHAR(13):CHAR(10)
NEXT I
MSG = MSG:CHAR(13):CHAR(10)
BOUNDARY=BOUNDARY:"--"
MSG = MSG:BOUNDARY:CHAR(13):CHAR(10)
*
* WRAP UP AND SEND
*
WRITE MSG ON UNIX.TMP.FILE, KEYID:".email"
MSG.PATH = "/tmp/":KEYID:".email"
*
EXECUTE '!/usr/sbin/sendmail -t -f ':FROM.EMAIL:' < ':MSG.PATH CAPTURING
OUTPUT RETURNING OUTPUT2
*
* DELETE TEMP EMAIL
*
DELETE UNIX.TMP.FILE, KEYID:".email"
RETURN
*

<dgraham (AT) storis (DOT) com> wrote

Quote:
I know this has been asked and answered several times before but I
can't seem to tease the information out of the net...

I want to send an e-mail via "mail", "Mail" or "sendmail" in *nix and I
want to include an attachments. Can someone give me a clue as to how
to do that from within PICK/U2?

Thanks in advance,

Dave




Reply With Quote
  #3  
Old   
frosty
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-10-2006 , 03:45 PM



http://groups.google.com/groups?as_q..._usubject=mail

--
frosty

dgraham (AT) storis (DOT) com wrote:
Quote:
I know this has been asked and answered several times before but I
can't seem to tease the information out of the net...

I want to send an e-mail via "mail", "Mail" or "sendmail" in *nix and
I want to include an attachments. Can someone give me a clue as to
how to do that from within PICK/U2?

Thanks in advance,

Dave



Reply With Quote
  #4  
Old   
frosty
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-10-2006 , 03:46 PM



Here's a shorter link:
http://makeashorterlink.com/?E5AF210FD

--
frosty

frosty wrote:
Quote:
http://groups.google.com/groups?as_q..._usubject=mail


dgraham (AT) storis (DOT) com wrote:
I know this has been asked and answered several times before but I
can't seem to tease the information out of the net...

I want to send an e-mail via "mail", "Mail" or "sendmail" in *nix and
I want to include an attachments. Can someone give me a clue as to
how to do that from within PICK/U2?

Thanks in advance,

Dave



Reply With Quote
  #5  
Old   
Symeon
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-11-2006 , 03:14 AM



easy !

use mutt


mutt -a {file to attach} -s {subject} emailaddress1 emailaddress2 <
/dev/null

e.g. mutt -a "/home/sym/output file.csv" -s "hello here is your file"
symeonb (AT) mymailer (DOT) com


rgds
Symeon.


Reply With Quote
  #6  
Old   
Symeon
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-11-2006 , 03:15 AM



easy !

use mutt


mutt -a {file to attach} -s {subject} emailaddress1 emailaddress2 <
/dev/null

e.g. mutt -a "/home/sym/output file.csv" -s "hello here is your file"
symeonb (AT) mymailer (DOT) com </dev/null


you need the input redirect (< /dev/null) if you dont want a message
body. If you do want a message body then redirect the body into the
command.


rgds
Symeon.


Reply With Quote
  #7  
Old   
dgraham@storis.com
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-11-2006 , 06:05 AM



While mutt looks like it would be easier to use than mail or sendmail,
I cannot be assuerd that it will exist on all of the systems that our
package is installed on. We don't always have complete control of the
environment in which we are running.

Thanks for the education though

Dave
Symeon wrote:
Quote:
easy !

use mutt


mutt -a {file to attach} -s {subject} emailaddress1 emailaddress2
/dev/null

e.g. mutt -a "/home/sym/output file.csv" -s "hello here is your file"
symeonb (AT) mymailer (DOT) com </dev/null


you need the input redirect (< /dev/null) if you dont want a message
body. If you do want a message body then redirect the body into the
command.


rgds
Symeon.


Reply With Quote
  #8  
Old   
dgraham@storis.com
 
Posts: n/a

Default Re: Sending w-mail with attachments via *nix - 10-11-2006 , 06:08 AM



Excellent - thanks for looking that up for me.

Of course now I feel like a lazy slug but then again I am a bit of a
slug. <grin>

Dave
frosty wrote:
Quote:
Here's a shorter link:
http://makeashorterlink.com/?E5AF210FD

--
frosty

frosty wrote:
http://groups.google.com/groups?as_q..._usubject=mail


dgraham (AT) storis (DOT) com wrote:
I know this has been asked and answered several times before but I
can't seem to tease the information out of the net...

I want to send an e-mail via "mail", "Mail" or "sendmail" in *nix and
I want to include an attachments. Can someone give me a clue as to
how to do that from within PICK/U2?

Thanks in advance,

Dave


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.