pradeepcr
6th March 2019, 16:47
We have a requirement to send an email with an attachment. Recipient information is in one of the custom tables. When the clicks on continue, a report has to be sent as an attachment in an email to the recipient.

We are on Baan 4c4 and latest service pack and porting set.

Thank you!!!

cmartin
8th March 2019, 11:12
We have a requirement to send an email with an attachment. Recipient information is in one of the custom tables. When the clicks on continue, a report has to be sent as an attachment in an email to the recipient.

We are on Baan 4c4 and latest service pack and porting set.

Thank you!!!

Hi!
what is you question? If you want to know how to send a mail I would recommend you to use the Baan eMessage Connector if available in B4. In case it's not available I would use some shell script or other executable.
As you arent using a question mark, it is hard to figure out what your question or problem is.

pradeepcr
8th March 2019, 16:47
Thanks for the response. We are using a device called 'OUTLOOK' where the report is sent as an attachment in an email from outlook. My question is - how to pass the recipient email address from the program script into the outlook message and also send the email behind the screen?

mark_h
10th March 2019, 20:05
I don' think the emessage connector is available in 4c4. What we did was just use sendmail - I assume that is available for Linux. Based off the other post you made on the topic. Is it an option?

pradeepcr
12th March 2019, 22:57
Mark,
sendmail is available in our Linux and we can use shell command in the program script. But cannot send the report as an attachment.

So used a device type called OUTLOOK and the argument calls the outlook API and attaches the report to email - issue here is we should be able to pass the email id and send the mail automatically with out user input required.

mark_h
13th March 2019, 14:37
Sorry we actually switched to mailx - and we used 2 different commands the uuencode I think makes the file an attachment.

cmd = "uuencode " &
err.file.name & " Errors.txt >> " & temp.file & " | mailx -s 'PeopleSoft/Baan Employee Errors (Automated Email)' " &
| strip$(email.addr) & "<" & temp.file

And in this case I think(not sure) - it send everything in the body of the message. You can even see where we did an update last year and I had to pause it because it was having a issue going out.

function send.some.msg(string mail.addr(1024), domain tppdm.cprj mail.cprj, string mail.body(255))
{
string temp.file(255), msgtxt(255), cmd(2048)
long inputfile, rc

| Create temporary file to copy the PC file to
temp.file = creat.tmp.file$(bse.tmp.dir$())
temp.file = strip$(temp.file)
inputfile = seq.open(temp.file,"w")
msgtxt = "Project " & strip$(mail.cprj) & strip$(mail.body)
rc = seq.puts(msgtxt, inputfile)
rc = seq.flush(inputfile)
rc = seq.close(inputfile)

cmd = "mailx -s " & chr$(34) &"Project " & strip$(mail.cprj) & chr$(34)& " " & strip$(mail.addr) & "<" & temp.file
rc = shell(cmd, SHELL_NO_OUTPUT)
suspend(2000) | 20180801 - add suspend to give the email a few seconds to get set.
rc = seq.unlink(temp.file)
}

pradeepcr
13th March 2019, 17:41
mailx worked similar to sendmail utility but not the attachment command did not work. it did not give any errors but does not do anything, not even an email is sent. Thanks for your help. Do let me know if you come across any other commands that can do attachments.

mark_h
13th March 2019, 18:50
Did you try with uuencode? I shelled out to unix and did this manually at the unix prompt:
uuendcode search.csh errors.txt>>test1.txt - this create the encoded file.
mailx -s 'Test' myemailaddress.com <test1.txt - mail the file

It came into my email as an attachment. Of course nothing in the body of the message but it was an attachment that I could read and see my shell script. Not pretty but it did work.

mark_h
13th March 2019, 18:55
I did it again but this time I did:
uuendcode search.csh errors.txt>>test1.txt - this create the encoded file.
cat search.csh errors.txt>>test2.txt
mailx -s 'Test' myemailaddress.com <test2.txt - mail the file

This time I got the script in the body of the message and as an attachment.

pradeepcr
19th March 2019, 18:59
This is my code.... it is not doing anything

e = shell("uuendcode mail.file>>test.txt", 0)
e = shell("mailx -s 'Test' mail.to <test.txt", 0)
suspend(2000)
e = shell("cat mail.file>>test2.txt", 0)

This code sends email but not as an attachment

e = shell("cp " & mail.file & " $HOME/stkomail ", 0)
e = shell("cat $HOME/Fileout" & " >> $HOME/stkomail", 0)
e = shell("/usr/sbin/sendmail -t -oi < $HOME/stkomail", 0)
e = shell("rm -f $HOME/Fileout" , 0)

mark_h
20th March 2019, 00:09
Do it by hand with a test. For uuencode I would add the copy command in front. When you shellout it typically runs in your home directory. I would login into baan, start a shell, manually run the copy, the uuencode (NOT Uuendcode - notice spelling) and the mailx.

e = shell("cp " & mail.file & " $HOME/stkomail ", 0)
e = shell("uuendcode mail.file>>test.txt", 0)
e = shell("mailx -s 'Test' mail.to <test.txt", 0)