You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

SQR: Email sent Successful but No Attachment (UNIX)

2 replies [Last post]
gpawar.ps's picture
User offline. Last seen 10 years 10 weeks ago. Offline
Joined: 02/06/2009
Posts: 10

Hello,

I have created SQR for sending email with .CSV file as an attachment on Unix. Everything is fine email is also generated and process is Successful, but there is no attachment to the email. Instead of it there is some non-readable text is appended to the email body.
----------------------------------------------

[Email Body]
644 Multi_Clm_Loaded.csv
M(%)E<&]R="!O9B!#;&%I;7,@=VET:"!A;B!%9F9E8W1I=F4@9&%T92!I;B!T
M:&4@4&%S="`-"D9E960@1&%T92Q#;VUP86YY+%!A>4=R;W5P+$-L86EM(%1Y
M<&4L4F5C;W)D(%1Y<&4L0VQA:6T@4W1A='5S($-D+$5M<&QI9"Q&:7)S="!N
[This data is near about 2/3 pages long]

------------------------------------------------------------------------------
My code is as below-
---------------------------------------------------------------
let $email_cmd = '(cat '||$filename_body||'; ux2dos'||' '|| $att_file1 ||' > '||$att_file2||'; ' ||'uuencode'||' '|| $att_file2 ||' '||'Multi_Clm_Loaded.csv)'||' '||'| mailx -s '||$Subject_Line ||' -r '||$emailaddress_from||' '||$emailaddress_to

call system using $email_cmd #status nowait

if #status > 0
SHOW 'Mail sent unsuccessful'
end-if
------------------------------------------------------------------

Where,
$filename_body = Text file with email body
$att_file1 = CSV file for attachment
$att_file2 = CSV file (will be used for attachment)
Multi_Clm_Loaded.csv = Name of the attachment file on email
$Subject_Line = String for Subject Line
$emailaddress_from = From email id
$emailaddress_to = To email id list

Observations:
-------------------
1. cat '||$filename_body||'; = Text in the body is correct- (OK)

2. ux2dos'||' '|| $att_file1 ||' > '||$att_file2||';= $att_file2 is also generating at specified Unix location. Data is also correct (OK)

3. ' ||'uuencode'||' '|| $att_file2 = I do not know how to verify it through code but file attachment is not available in the email. Some garbage text is appended to the email body. (KO)

4. ||' '||'Multi_Clm_Loaded.csv) = Not able to verify as no attachment (KO)

5. '||' '||'| mailx -s '||$Subject_Line ||' -r '||$emailaddress_from||' '||$emailaddress_to = This part is OK. Everything is correct. (OK)

Earlier (other SQR), I have used same piece of code for attachment of .LOG file.
Though it was giving same issue for Outlook/Gmail etc. but working fine for "Lotus Notes" And client is on Lotus Notes so we delivered it to client :)
But for .CSV file attachment it is giving this issue on Lotus Notes too.. :((

Please let me know if I am missing anything.
I am doing it on UNIX.

Regards,
Ganesh Pawar

Regards,
Ganesh Pawar

Lepa's picture
User offline. Last seen 1 year 38 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: SQR: Email sent Successful but No Attachment (UNIX)

Great problem explanation but can't really see the problem :(. I can show you what I've done in the past, may be that would help you out somehow!

!Sending file from UNIX to Window
Let $myfile = $filename || '.csv'
Let $Command = 'uuencode' || $myfile || $myfile || > 'mailfile'
Call System Using $Command #Status
If #Status <> 0
       Show 'Problem with file'
End-if
Call System Using 'mail "Emailing Report"  < mailfile' #status
If #Status <> 0
       Show 'Problem with sending file = ' #Status
End-if

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

gpawar.ps's picture
User offline. Last seen 10 years 10 weeks ago. Offline
Joined: 02/06/2009
Posts: 10
Re: SQR: Email sent Successful but No Attachment (UNIX)

I have resolved this issue. This information will be helpful for those who are facing similar issue.
I have below code to overcome this issue-

#ifdef UNIX
let $emailaddress_to = $emailaddress_to||'gpawar@gmail.com'
let $emailaddress_from = 'gpawar.p@gmail.com'

Let $Subject_Line1 = 'LOG File - '|| $AsOfToday
Let $Subject_Line = '"'||$Subject_Line1 ||'"'

let $filename_body = '{MET_OUT_PATH}Success_EmplID.log'

let $att_file1 = '{MET_OUT_PATH}Err_EmplID.log'
let $att_file2 = '{MET_OUT_PATH}Err_EmplID-'||$AsOfToday||'.log'

let $email_cmd_log = '(cat '||$filename_body||'; ux2dos'||' '|| $att_file1 ||' > '||$att_file2||'; ' ||'uuencode'||' '|| $att_file2 ||' '||'Error_'||$AsOfToday||'.CSV)'||' '||'| mailx -s '||$Subject_Line ||' -r '||$emailaddress_from||' '||$emailaddress_to

call system using $email_cmd_log #status nowait

if #status > 0
SHOW 'Email-Log Mail sent unsuccessful'
end-if
Show 'After Call'

#else
show 'Not running on Unix no automated email of file '
#end-if

Regards,
Ganesh Pawar

Regards,
Ganesh Pawar