layswan
3rd March 2014, 04:24
Hi,
i am customizing a session to submit user service request in ERP LN and i want the system automatic send an email to inform MIS ppl once the user submit the request. What should i write in the prgram script to send an email once the user click submit?
Anyone help please! :(
Thanks!
bhushanchanda
3rd March 2014, 20:30
Hi,
You have to set some parameters in the E-message connector for using SMTP or OUTLOOK. And then you can use this link (http://www.baanboard.com/programmers_manual_baanerp_help_emessage_connector_examples) to get an example of how to send the email using one of this service. Else there are other tools which you can use like blat, sqlmail etc to send mail at real time.
layswan
7th March 2014, 08:00
Hi,
Thanks for the reply!
I am successfully send the email using SMTP service and below is the code i wrote in my program script. But how to put my message content in the email?:(
function send.mail()
{
compnr.check(0)
service = "SMTP"
recipient.address = "xxx@test.com.my"
recipient.name = "Tracy"
mid = create.xml.header()
if mid <> 0 then
stat = cmf.startService(service,2)
if stat <> 0 then
message("Message could not be sent (Infor ERPLN eMessage Connector service did not start)")
exit()
endif
stat = cmf.send(mid,service)
suspend(2000)
if stat <> 0 then
message("Message could not be sent (Infor ERPLN eMessage Connector service refused message)")
cmf.stopService(service,2)
exit()
endif
stat = cmf.stopService(service,2)
endif
compnr.check(999)
}
function long create.xml.header()
{
long message.ID
long from.ID
long to.ID
long attachment.ID
long ret
message.ID = cmf.create()
ret = cmf.setClass(message.ID, "CMF.NOTE.EMAIL")
ret = cmf.setSubject(message.ID, "TRIL - Electronic Payment Advice")
from.ID = cmf.createRecipient(message.ID, ttcmf.role.from)
ret = cmf.setRecipientName(from.ID, "Transformers & Rectifiers (I) Ltd.")
ret = cmf.setRecipientAddress(from.ID,"yyy@test.com.my")
ret = cmf.setRecipientType(from.ID, "SMTP")
to.ID = cmf.createRecipient(message.ID, ttcmf.role.to)
ret = cmf.setRecipientName(to.ID, recipient.name)
ret = cmf.setRecipientAddress(to.ID, recipient.address)
ret = cmf.setRecipientType(to.ID, "SMTP")
ret = cmf.setRecipientResponsibility(to.ID, "TRUE")
return(message.ID)
}
Please advice!
Thanks!
JaapJD
7th March 2014, 09:15
Use cmf.createAttachment, cmf.setAttachmentMime, cmf.setAttachmentFilename and cmf.setAttachmentBody for this. The last one is to make distinction between the body itself and separate file attachments.
layswan
11th March 2014, 10:15
Hi,
Thanks for the reply!
I used cmf.setAttachmentBody in my programme script, the email that the end user received is a file attachment with empty email message.
I think the cmf.setAttachmentBody is to email attachment.
Actually I want to write a message in the email message content itself but not in the attachment. Anyone help? :(
Thanks!
JaapJD
11th March 2014, 10:20
The body is a 'normal' attachment. The cmf.setAttachmentBody must be used to indicate that this specific attachment is the body:
ret = cmf.setAttachmentBody(att, ttyeno.yes)