Operating System - HP-UX
1829119 Members
1866 Online
109986 Solutions
New Discussion

send attachment in batch with elm ? is it possible

 
vikmos
Occasional Contributor

send attachment in batch with elm ? is it possible

Hi, I'm relatevely new to Unix , and still trying to send attachment file (user wants it as exactly an attachment) in batch mode i.e. running shell.
But can't do it, from reading %man I start thinking that it not possible at all ? Am I right ? I've got sample from one buddy :
(in shell)
....
elm -s "$SUBJECT" -i $ATTFILE -a $MAILTO < $BODY >>$LOGFILE
....
My logfile says:


if elm can't do this, anybody give me lead what command can.
12 REPLIES 12
Geoff Wild
Honored Contributor

Re: send attachment in batch with elm ? is it possible

Download and install mpack:

http://hpux.ee.ualberta.ca/hppd/hpux/Users/mpack-1.5/

"mpack/munpack version 1.5 for unix

Mpack and munpack are utilities for encoding and decoding
(respectively) binary files in MIME (Multipurpose Internet Mail
Extensions) format mail messages. For compatibility with older forms
of transferring binary files, the munpack program can also decode
messages in split-uuencoded format.}"

Great for attaching any kind of document...



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steven E. Protter
Exalted Contributor

Re: send attachment in batch with elm ? is it possible

Yes, you need a later version of elm.

Or you can use the cool script I'm attaching.

Enjoy.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dave La Mar
Honored Contributor

Re: send attachment in batch with elm ? is it possible

We use mailx here in a multitude of scripts with/without attachments, letter body, cc and bc.
Attached is the gist of what you wnat in your scripts. This is a down and dirty cheat sheet for our new scipters.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Steven E. Protter
Exalted Contributor

Re: send attachment in batch with elm ? is it possible

I mistyped. heh heh. elm is not a batch tool.

It only does attachments interacively.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
harry d brown jr
Honored Contributor

Re: send attachment in batch with elm ? is it possible

uuencode filename filename.filetype | mailx -m -s "subjecthere"

live free or die
harry
Live Free or Die
Coleman Blake_2
Advisor

Re: send attachment in batch with elm ? is it possible

Here's what I use, thanks to Ms. Workman. Assign her the points, not me.

Rita C Workman


August 09, 2000 20:04 PM GMT [ unassigned ]

--------------------------------------------------------------------------------
I've seen similar requests for this on other messages...and I have sent this before. So I'm sending it again to you...Yes- you can send a file as a TRUE file attachment and actually preserve what the file is...here is the info:
First make sure you at least have Elm 2.4 on your box, and my example is for a HPUX 10.20 (you need MIME capability) so be sure you have patch PHNE_15835 (it doesn't cause a reboot to load).
The next thing you have to do is create a small file (ex include.file) that is used to send the file as an attachment. There are a few things you could read on this for more details at HP's IT Resource if you want. But simple create a file with this syntax:
[include text.txt text/plain base64]

where text.txt is your file.

The general format is: [include filename type/subtype encoding]
type/subtype= text/plain, image/gif, image/jgp etc..
encoding=base64, quoted-printable etc...
Another example might be for a Word doc:
[include file.doc application/msword base64]

Now from the command line to send this file as an attachment to user_abc:

elms -s 'Test attachment file' user_abc@your_org.com ============================================

What this did was email to user_abc@your_org.com the file test.txt with a subject line of Test attachment file. If you sent a Word doc it would come across and be a Word file attachment. It works.
You can do it with text files; image.jpg or gif files; and more. Just change the include stmt like.....And you can use this and build it right into job streams, so you can then email reports and files when batch jobs are done....It's a real paper saver.
If you want to do some lookups on IT Resource for more info.

Coleman Blake
Peace Corps
A. Clay Stephenson
Acclaimed Contributor

Re: send attachment in batch with elm ? is it possible

Elm will work just fine from the command line and it's quite easy. I have scripts that use it that are run everyday.

Within the body of your email add this:

------------------------------------

This is my text. How are you?


[include /tmp/myattach application/octet-stream base64]

This is some more text in the middle.

[include /tmp/myexcel.xls application/ms-excel base64]

This is a closing message in the email.

----------------------------------------



That will attach /tmp/myattach and /tmp/myexcel.xls. You can include multiple attachments using this method. If you are running 10.20 make sure that you have a MIME enabled version of elm (PHNE_15835 or later).

Then to use it from a script:
elm -s "My Subject" user@mailserver.com < myletter

Where myletter contains the attachment include statement as well as your message text. It is also necessary that you have a .elm directory
under the senders home directory because unlike the interactive version of elm the command-line version will not create a .elm directory automatically.

Regards, Clay
If it ain't broke, I can fix that.
vikmos
Occasional Contributor

Re: send attachment in batch with elm ? is it possible

Thanks to all for info, so far none of mailx or elm combination works for me, but I need more time to digest all info and work with System guys (I'm not) to check all settings.

I just stress that I need do it running cron shell, NOT from command line, and file should be as a real attachment.

Running shell:
ux2dos /home/devel/att | uuencode att.text | mailx -m -s $SUBJECT $MAILTO < $BODY

I got the following as a system output on my terminal:
===============================================
Develd01 [/home/devel]
$ UNIX... User unknown
from... User unknown
/home/devel/dead.letter... Saved message in /home/devel/dead.letter
^C

dead.letter file doesn???t give any exceptions and email comes to proper $MAILTO address with $BODY text but without attachment att.txt + my subject from $SUBJECT replaced with just ???mail??? (probably originated by system).


Will keep all posted. Thanks to all.
Send it, alive or dead !!

Vittorio
A. Clay Stephenson
Acclaimed Contributor

Re: send attachment in batch with elm ? is it possible

Elm will work just fine from cron but you must make certain that you set and export PATH so that all commands will be found. You will need to modify the body of your email to use the [include ..] syntax but the beaty of this method is that many attachments (as well as just one) can be done.
If it ain't broke, I can fix that.
vikmos
Occasional Contributor

Re: send attachment in batch with elm ? is it possible

Thanks, Clay for optimistic note.
When you mentioned , should I use it with elm or mailx? As I couldn't found too much info on .
Also so far I'm running my shell from command line making first so it should be any problems with PATH export ?

Include att text/plain base64
Elm ???s $SUBJECT $MAILTO < att

Thanks
Vittorio
A. Clay Stephenson
Acclaimed Contributor

Re: send attachment in batch with elm ? is it possible

The home directory is not needed in PATH but you do need to make certain that the path to elm (usually /usr/bin/) is in ${PATH}. Cron has an intentionally very sparse environment so any commands invoked from within your script will need full pathnames or the PATH variable must be set and exported.

See my above posting that illutrates how to use an include cluase within the body of the email. It is also necessary to create a .elm directory in the sender's home directory because the command-line version of elm will not automatically create a .elm directory if one is not found.
If it ain't broke, I can fix that.
Rita C Workman
Honored Contributor

Re: send attachment in batch with elm ? is it possible

My explanation above had one significant error...on the line where it mails using elm.... I left out the include file..

elms -s "test message touser@any.com < from-include.file

We found using the include file method works for anything we need to send...and it works well when you have to script it in for daily mails too...from Word documents to tiff files, etc. And the software is free and already on your server from version 11.0 on......(MIME..).
Glad to see Clay even likes it...

Kindest Regards,
Rita