Automating Mail Process

HI
i would not mind renaming Folder name or script renaming the files in the attachments directory.i already renamed this particular file from

RFQ - Medical - 15-05- 2016.xlsx (containing whitespace characters)

to just RFQ.xlsx
But still it is unable to send the attachment.Please share your input.

Thanks
Rajnikant

Please change the script to:

#!/bin/bash
ATTACHMENT_DIR="/home/sreenivasa/Desktop/ATTACH"
ATTACHMENTS=
BODY_FILE="/home/sreenivasa/Desktop/Testing.txt"
SUBJECT="linux mail send attachment example"
TO_LIST="rajnikant875@gmail.com,sinha6315@gmail.com,rajnikant@gytechs.com"

# Gather list of attachments:
for file in "$ATTACHMENT_DIR"/*
do	[ ! -f "$file" ] && continue
	ATTACHMENTS="$ATTACHMENTS -a $file"
done

# Send the message.
mail -s "$SUBJECT"  $ATTACHMENTS "$TO_LIST" < "$BODY_FILE"

and try again.

hi sir
this code is working fine.one more request can script read the CC_LIST email id from some text files which is located on Desktop instead of directly specifying in the script.

thanks
Rajnikant

Hi jajnikant,
We are here to help you learn how to write scripts on your own; not to act as your unpaid programming staff.

Of course a shell script can read data from a file and save that value in a variable. (But, as noted before, your mail command is not sending any messages to a carbon copy list; only to a distribution list. Do you want to start sending your message to a carbon copy list as well as the distribution list that is current built-in to your script, or do you just want to read the distribution list from a file?) Look at the man page for your shell on your system (try man bash ) in the SHELL BUILT-IN COMMANDS section for the description of the "read" built-in utility to see if you can make that do what you want. If you can't, show us what you have tried and we'll help you fix it.

  • Don