Operating System - HP-UX
1832858 Members
3617 Online
110048 Solutions
New Discussion

send attachment via elm from command line

 
SOLVED
Go to solution
Christy Stocky
New Member

send attachment via elm from command line

I am trying to send an ascii attachment via elm. This is working for me when I explicitly specify the filename in the include statement. However, the filename I need to e-mail changes on a daily basis, according to the date.

This is what I am trying:
1. filename=/uxx/xxx/xxxx.txt (I use absolute path and filename when setting $filename).
2. elm -s "test" me@trtn.com < include.file
3. My include.file looks like this:
[include $filename application/octet_stream base64]

It doesn't like the use of a variable in the include statement (says Include file can't be found)...is there a way around this? I have also played with "uuencode $filename $filename|sendmail me@trtn.com", but this produces a binary file....I need the attachment to be an ascii text file.

Any suggestions would be greatly appreciated.
4 REPLIES 4
Maureen Gunkel
Trusted Contributor
Solution

Re: send attachment via elm from command line

Christy:
You could create the include.file 'on the fly', so to speak. When you know what the $filename is going to be, youcan issue the following command:
echo "[include" $filename "application/octet_stream base64]" > include.file
Then elm won't have a problem with the filename substitution.
HTH
No matter where you go, there you are.
Frederic Soriano
Honored Contributor

Re: send attachment via elm from command line

Hi Christy,

I am not really familiar with elm MUA, but have you tried sending your file this way:
elm -s "test" me@trtn.com < /uxx/xxx/xxxx.txt ?

Each time I want to send an attached ascii file
to a mail, I am issuing:
mailx -s "test" me@trtn.com < myfile

And it works perfectly !

I hope this helps.

Regards.
Frederic Soriano
Honored Contributor

Re: send attachment via elm from command line

Oops. I spoke too fast! I just remembered that I wrote a script using elm, and that I have to deal with such problem...

You just need to edit the file to be sent as an attachment, and put the following line first (assuming your file is named filename.txt):
[include filename.txt text/plain base64]

And then run elm -s "test" me@trtn.com < /path/to/your/filename.txt

And this should do the trick!

But you can also consider mailx, hich is also great!

Regards.
Christy Stocky
New Member

Re: send attachment via elm from command line

Ok, Maureen's suggestion worked. It was a great solution that I should have seen without posting a question :). Thanks, Maureen.

I had already tried the method suggested by Frederic, but the attachment would include the "include" statement, it doesn't get stripped out. The file I am sending is a fixed format datafile, ready for loading into a database, and I did not want to request that they skip the first line.

It's perfect now, thanks a lot for the suggestions.