unix email attachments in web mail

Hi,

Request you to please help on my issue.

My issue is: We are able to send the log files as an email attachment. We are able to get the attachment in our inbox. But when we try to see in web mail, instead of the attachment, junk characters are displaying.
Appreciate your help.

Regards,
Srinivas

If you search the site, there are lots of e-mail examples. Try this to attach a file called data.txt:

#!/bin/ksh

# Convert line feeds from the source and write to attach.out.
unix2dos -437 -ascii data.txt attach.out

# Now uuencode attach.out and call it data.txt for the attachment name.
(print "Please review the attached file";uuencode attach.out data.txt) | mailx -s "Test" myemail@mydomain.com

exit 0

Hi Gary,

Thank you for the update.
Used the code specified by you. But its not working.

I have used the following:

FILE="$APPLCSF/$APPLLOG/l$V_REQUEST_ID.req"

Here FILE is a var that contains the log file.

unix2dos -437 -ascii $FILE $FILE

uuencode $FILE $FILE) | mailx -s "$V_EMAIL_SUB" "$V_EMAIL_ADDRESS"

Is there anything im missing.

Regards,
Srinivas

If you're going to remove the print, remove the extra ) on the other side too.

Hi Corona,

Actually im trying to corelate the same to my code. its not working as expected.

still junk chars displaying instead of the attachment in web email.

Regards,
Srinivas

The code you posted wouldn't have worked at all due to the extra )...

Hi Corona,

Actually the code is like this as shown below:

V_EMAIL_ADDRESS=$5
V_REQUEST_ID=$6
V_EMAIL_SUB=$7
V_COMPLETION_STATUS=$8
V_USER_NAME=$9
V_COMPLETION_TIME=${10}

echo "Email parameter: $5"
echo "Request parameter: $6"
echo "Subject: $7"
echo "Completion Status: $8"
echo "User Name: $9"
echo "Completion Time: ${10}"

#echo "-------------------------------------------------------"
#V_EMAIL_ADDRESS="Emailparameter"
echo "-------------------------------------------------------"

echo "-------------------------------------------------------"
#V_EMAIL_ADDRESS="srinivas.ginyarpalli@oracle.com"
echo "-------------------------------------------------------"
echo "Email Address  "$V_EMAIL_ADDRESS

#V_EMAIL_SUB="$V_EMAIL_SUB:$V_REQUEST_ID"
#V_EMAIL_SUB="XXCB Ricoh Request status Report for RIF Request ID: $request_id"
echo "Email Subject:"$V_EMAIL_SUB
echo "Request id:"$V_REQUEST_ID
echo "Completion Status:"$V_COMPLETION_STATUS
echo "User Name:"$V_USER_NAME
echo "Completion Time:"$V_COMPLETION_TIME


#echo "Out file"o$request_id
#/usr/bin/uuencode $APPLCSF/out/$CONTEXT_NAME/o$request_id.out XXCB_ERROR_WARNING_REPORT.out|mailx -s "${V_EMAIL_SUB}" ${V_EMAIL_ADDRESS}

FILE="$APPLCSF/$APPLLOG/l$V_REQUEST_ID.req"

echo $FILE

###############
# Convert line feeds from the source and write to attach.out.
#unix2dos -437 -ascii data.txt attach.out
#unix2dos -437 -ascii $FILE

# Now uuencode attach.out and call it data.txt for the attachment name.
#(print "Please review the attached file";uuencode attach.out data.txt) | mailx -s "Test" myemail@mydomain.com
###############

############################################
if test -r $FILE
then
(echo "Hi,"
echo "Please find the Errored Concurrent Program details below:"
echo ""
echo "---------------------------------------------------------"
echo "Email Subject:"$V_EMAIL_SUB
echo "Request id:"$V_REQUEST_ID
echo "Completion Status:"$V_COMPLETION_STATUS
echo "User Name:"$V_USER_NAME
echo "Completion Time:"$V_COMPLETION_TIME
echo "---------------------------------------------------------"
echo ""
echo "Thanks and Regards,"
echo "System Administrator"
uuencode $FILE $FILE) | mailx -s "$V_EMAIL_SUB" "$V_EMAIL_ADDRESS"

#(echo "Email text" ; uuencode $FILE  $FILE) | mailx -s  "$V_EMAIL_SUB" $V_EMAIL_ADDRESS
 #mailx -s  "$SUBJECT" -c   $EMAILCC $EADDRESS
 #uuencode  $FILE email_$V_REQUEST_ID.txt > eout_$V_REQUEST_ID.txt
 
 #cat $XBOL_TOP/bin/message.txt FILE > Consign_$V_REQUEST_ID.txt
 #cat $FILE > Consign_$V_REQUEST_ID.txt
 echo " ---- Send Email to --> "$V_EMAIL_ADDRESS
 #mailx -s "$V_EMAIL_SUB" $V_EMAIL_ADDRESS < Consign_$V_REQUEST_ID.txt
 #reerecho " ---- Removing the runtime files ----"
 #rm eout_$V_REQUEST_ID.txt
 #rm Consign_$V_REQUEST_ID.txt
 echo " ------------------------------------"
fi
############################################

#cat $FILE | mailx -s "${V_EMAIL_SUB}" ${V_EMAIL_ADDRESS}

if [[ $? -ne 0 ]]; then
   echo "Error: Unable to email $FILE to $V_EMAIL_ADDRESS"
else
   echo "Success: Sent $FILE to $V_EMAIL_ADDRESS"
fi

The issue is that the attachment is fine if we open thru our inbox. If we open the same thru web mail, then the junk chars its showing.
Regards,
Srinivas

How is valid attachments showing as garbage, a bug in the script?

Hi Corona,

I don't think so, but im just thinking of some MIME issues in web mail. The same is perfectly fine with the email in inbox(outlook).

Regards,
Srinivas

There is much variation in "mailx". Please post what Operating System and version you have.
In mine I need a "-m" switch to turn off Mime headers.
Also, after removing all the comments from your script, you never execute "unix2dos". In the example earlier the "unix2dos" command line was wrong.
The pipeline sequence snippet would be something like:

unix2dos ${FILE}|uuencode "myattach.txt")|mailx -s .....

Notice that I have given the attachment a ".txt" extension. This is quite likely to be your problem because your original file has a ".req" extension and a huge full path name.

Hi methyl,

My OS is Linux
Yes, we are attaching the log file of the concurrent program. If possible, could you please modify my script to work for the web email

Regards,
Srinivas