Rajg_baan
27th May 2015, 16:29
Hi ,

Can I email a file ( generated from one baan job) on unix system to user outlook ? No manual interaction. File should go to user outlook automatically.

If device data is the answer, How should we configure that device?

Thanks,
Raj

mark_h
27th May 2015, 17:41
Yes - just search this forum email or outlook. There are plenty of threads with examples included. Basically no device is needed we use mailx (assuming setup on your system). The report is written to a temp file and then we mail it out to the user.

Rajg_baan
28th May 2015, 15:39
Thanks Mark,

I have searched and tried some methods to email a unix file to outlook from baan. I have not succeeded 100 % . I am able to email job output to user's outlook by using mailx command in device data args fields (
ASCII\cat %s|mail emailId ) . In this case job output is not saved anywhere.

My requirement is to email an unix file which is generated by a job. I want that file to be saved in unix and email as well.
I can send it from unix command line or from cron.
But I want it to be done from baan. Can you help me here?

Thanks,
Raj.

bhushanchanda
28th May 2015, 16:30
You can use shell() function to run the unix commands from Baan script.

Or, use run.prog() function to run a shell script on server.

Also, explore CMF functionality

CMF Example (http://www.baanboard.com/programmers_manual_baanerp_help_emessage_connector_examples#1)

Also, check this thread (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1753) which has a lot of discussions on sending emails.

Also, for creating a file at some particular place, you can use seq.* functions and use the same file as an attachment.

mark_h
28th May 2015, 18:39
And here is some simple code that does it for us. Basically reads a list of email addresses and sends a report created to the user.

function send.out.email()
{
string cmd(1000)
string email.file.name(256) | email.lst
long email.fp
string email.ident(1)
string email.addr(100)

email.file.name = in.dir & "email.lst"
if not open.file(email.fp, email.file.name, FTYPE.READ) then
return
endif


rc = seq.gets(buf, 1094, email.fp)

| 20081106 encode the file out side the loop - if not each each successive
cmd = "uuencode " & err.file.name & " Errors.txt >>" & temp.file
rc = shell(cmd, SHELL_NO_OUTPUT)

while not seq.eof(email.fp)
email.ident = buf(1;1)
email.addr = buf(3)
cmd = "mailx -s 'Errors (Automated Email)' " &
strip$(email.addr) & "<" & temp.file

if email.ident = "A" then
rc = shell(cmd, SHELL_NO_OUTPUT)
else
if email.ident = "E" and err.flag then
rc = shell(cmd, SHELL_NO_OUTPUT)
endif
endif
rc = seq.gets(buf, 1094, email.fp)
endwhile
rc = seq.close(email.fp)

}

manish_patel
28th May 2015, 23:47
Thanks Mark,

I have searched and tried some methods to email a unix file to outlook from baan. I have not succeeded 100 % . I am able to email job output to user's outlook by using mailx command in device data args fields (
ASCII\cat %s|mail emailId ) . In this case job output is not saved anywhere.

My requirement is to email an unix file which is generated by a job. I want that file to be saved in unix and email as well.
I can send it from unix command line or from cron.
But I want it to be done from baan. Can you help me here?

Thanks,
Raj.

Interesting to know why output file getting removed, as you are not specifying anything to remove the output file like rm %s and as per my knowledge, mail command will not remove the output file.

Alternatively,
You can write shell script with mail or other command as per your requirement. And link the job to this shell command to send the output file (i.e. generated by previous job step).

mark_h
29th May 2015, 00:31
I see what you and manish are saying. We have jobs that run and generate reports in ASCII format to a directory on our UNIX server. In the example I posted the session generates the file into a directory. The code you see then runs and sends the output file to a user. But if I wanted to I could create another baan session, using the above code where the user could input a file name and click a button to sent it. I could ask for a list of email address and do it all at once.

Now if you have an out file disappearing that will be a different issue. I know in baan 4 there is a setting on user id for how long output is saved. On our system the $BSE/tmp files are cleaned regularly and user out is only kept for maybe a day or two. I know I can't jump in and re-print a report to disc from a week ago. This is why on important sessions or jobs, the output goes into ascii files in a different directory.

Not sure if this helps or not.

vahdani
31st May 2015, 17:05
Hi,

you can alwas use the LN eMessage Connector functionality (CMF). Please find attached my documentation of how to setup this in LN and how to send Mails either by printing to a new Printer device or per own programming to register mail request to a temporary (proprietary) mails-table and then calling another program to send these mails.