General
cancel
Showing results for 
Search instead for 
Did you mean: 

send mail with embedded html plus .xls attachment

 
Lynne Frazier
Occasional Advisor

send mail with embedded html plus .xls attachment

I'm new to HP-UX and need some assistance in sending an email containing HTML body and a .csv attachment. I've found
numerous posts on the forum that discuss variations of this, however I cannot find a solution for this particular scenario.

My .html file looks something like this:

# cat email.html


Sample HTML file





I'm able to send the html formatted email with no attachments using the following code:

cat email.html \
| /usr/lib/sendmail -t "someone@domain.com"

=====================================
When I update the code to include the attachement as follows, the email is sent with the attachment but the email body is missing:

echo "To: $p_email\nSubject: $month $year Subject\n" > $mailfile
(cat email.html; \
uuencode ${ofile1} ${ofile1} >> $mailfile) \
| /usr/lib/sendmail -t < ${mailfile}

=====================================
Next I tried the following and received the inline html email body but the .csv file was corrupt.

export MAILTO=someone@domain.com
export SUBJECT="Test Waiver Code email"
export BODY=email.html
export ATTACH=wcode_hdr.csv
EMAIL_BOUNDARY_STRING=Z${RANDOM}${RANDOM}${RANDOM}${RANDOM}

(
echo "To: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="${EMAIL_BOUNDARY_STRING}"'
echo '--${EMAIL_BOUNDARY_STRING}'

echo "Content-Type: text/html charset=us-ascii"
echo "Content-Disposition: inline"
cat $BODY
echo '--${EMAIL_BOUNDARY_STRING}'
echo "Content-Transfer-Encoding: base64"
echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
uuencode $ATTACH $(basename $ATTACH)
) | /usr/sbin/sendmail $MAILTO

Any suggestions?

Thanks
15 REPLIES 15
Steven E. Protter
Exalted Contributor

Re: send mail with embedded html plus .xls attachment

Shalom,

http://hpux.ws/mailfile2

Try that script.

Change the flipping email address though so my mailbox doesn't get filled.

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
Steven E. Protter
Exalted Contributor

Re: send mail with embedded html plus .xls attachment

My bad,

http://hpux.ws/mailfile2

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
Jose Mosquera
Honored Contributor

Re: send mail with embedded html plus .xls attachment

Hi,

Please take a look to attached file.

Rgds.
Lynne Frazier
Occasional Advisor

Re: send mail with embedded html plus .xls attachment

Steven,

It appears your example only sends an email with a file attached. I need to attach a file as well as include inline html for the message body.

Thanks
Jose Mosquera
Honored Contributor

Re: send mail with embedded html plus .xls attachment

Hi Lynne,

Have you reviewed my attachment?

Rgds.
Lynne Frazier
Occasional Advisor

Re: send mail with embedded html plus .xls attachment

Jose,

I tried your example and received the email with the attachement (not corrupted), but the inline html for the message body did not display correctly. It displayed as a single text line of "email.html" instead of the actual verbiage within my file.

I used your code as follows:

MAILTO=someone@domain.com
SUBJECT="Test Waiver Code email"
FROM=host@domain.com
BODY=`cat email.html`
ATTACH=wcode_hdr.csv
#
#And this last one send both of them, inside email body and an attachment:

(echo "Subject:$SUBJECT\nTo: $MAILTO\nImportance:High\n\n$BODY";uuencode $ATTACH $ATTACH)| /usr/sbin/sendmail $MAILTO

Thanks

Lynne Frazier
Occasional Advisor

Re: send mail with embedded html plus .xls attachment

Jose,

Correction, I see a mistake in my code where I didn't cat the email.html file. I fixed that but still the actual html code with tags is displayed in the email body as opposed to the inline formatted html verbiage.

Lynne
Jose Mosquera
Honored Contributor

Re: send mail with embedded html plus .xls attachment

Hi,

Try this:

(echo "Subject:$SUBJECT\nTo: $MAILTO\nImportance:High\n\n`cat email.html`";uuencode $ATTACH $ATTACH)|/usr/sbin/sendmail $MAILTO

Rgds.
Lynne Frazier
Occasional Advisor

Re: send mail with embedded html plus .xls attachment

Jose,

I get the same results, the html is not formatted, the email body displays as follows:


Content-Transfer-Encoding: 7bit
Content-Type: text/html charset=us-ascii

Hello all,



Please find the February 2011 waiver codes. These waiver codes are intended for your use only and should not be forwarded to any other recipients. Thank you!