VishalMistry
6th July 2011, 11:34
Hi,
We have a session that creates a .csv file and sends the same programatically through eMessage connector API. The problem is, when the mail reaches recepient, name and extension of the attachment changes (e.g. file.csv to ATT000001.RTF).
Anybody facing similar issue. Pl guide.
Vishal
bdittmar
6th July 2011, 12:31
Hi,
We have a session that creates a .csv file and sends the same programatically through eMessage connector API. The problem is, when the mail reaches recepient, name and extension of the attachment changes (e.g. file.csv to ATT000001.RTF).
Anybody facing similar issue. Pl guide.
Vishal
Hello,
Have a look at:
How to use the eMessage Connector API to construct and send a message
In this example function cmf.send is used to send the message. The main difference with cmf.sendToPerson (see next section for an example) is that when using cmf.send only the message id is suplied as an argument, while cmf.sendToPerson needs both a message- and an addresslist id. This means cmf.send sends the message to the recipients in the message object, while cmf.sendToPerson sends the message to the recipients in the addresslist object.
|******************************************************************************
|* CMF Sample Code
|******************************************************************************
|* Script Type: 0
|******************************************************************************
dllusage
Desc: This code sample demonstrates the use of some of the Infor
ERP LN eMessage Connector commands
described in the CMF 4GL Functional Design. It accepts a
filename (which points to an RTF
document), Infor ERP LN eMessage Connector service name,
recipient name and recipient address
(SMTP only) as input arguments. It then uses the Infor ERP
LN eMessage Connector commands to
construct a message then send it to the indicated
recipients.
Pre: None.
Post: The file is sent to the appropriate Infor ERP LN eMessage
Connector service.
In: The four program arguments accepted are:
sourcefile: The name of the file (RTF format) to be
sent.
service: This is the name of the service that will
be used to send the message.
This must be name of a valid Infor ERP LN eMessage
Connector service
name: This is the (human readable) name of the recipient.
address: This the address where the file should be
sent. This could be an email address,
a fax number, etc.
Out: None.
enddllusage
string recipient.address(80) |Recipient address
string recipient.name(80) |Human readable name of the
recipient
string sourcefile(256) |Filename of the source
file
function main()
{
domain ttcmf.prov service |Infor ERP LN eMessage
Connector service for transporting messages
long stat |Variable to hold return values
long mid |CMF message id
|Switch to company 0
compnr.check(0)
|Get program arguments
sourcefile = strip$(argv$(1))
service = strip$(argv$(2))
recipient.name = strip$(argv$(3))
recipient.address = strip$(argv$(4))
|Build message XML header
mid = create.xml.header()
|Send message
if mid <>0 then
stat = cmf.startService(service,2)
if stat<>0 then
message("Message could not be sent (Infor ERP
LN eMessage Connector service did not start)")
exit()
endif
stat = cmf.send(mid,service)
if stat<>0 then
message("Message could not be sent (Infor ERP
LN eMessage Connector service refused message)")
cmf.stopService(service,2)
exit()
endif
stat = cmf.stopService(service,2)
endif
}
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")
ret = cmf.setSubject(message.ID, "Sample CMF Message")
|Set FROM recipient
from.ID = cmf.createRecipient(message.ID, ttcmf.role.from)
ret = cmf.setRecipientName(from.ID, "John Doe")
ret = cmf.setRecipientAddress(from.ID,"jdoe@example.com")
ret = cmf.setRecipientType(from.ID, "SMTP")
|In reality of course the from address could be filled from
the
|Address book.
|Set TO recipient
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")
|Set attachment
attachment.ID = cmf.createAttachment(message.ID)
ret = cmf.setAttachmentBody(attachment.ID, "TRUE")
ret = cmf.setAttachmentMIME(attachment.ID,
"application/rtf")
ret = cmf.setAttachmentFileName(attachment.ID,sourcefile,
"Sample
Attachment")
return(message.ID)
Regards
VishalMistry
7th July 2011, 07:26
Hi Mr.Bernard,
Yes I am following the the same code and mail successfully reaches to recepient with attachment. The only issue is name and extension of attachment changes once it reaches recepient.
If I see, eMessage connector log and check the mail sent, the attachment name is shown proper in the log (file.csv and not ATT00001.RTF).
Pl guide if there is any specific code for setting attachment type and attachment name. I am attaching my code for reference.
Vishal
mark_h
7th July 2011, 16:00
Does this help http://www.baanboard.com/baanboard/showthread.php?t=58443.
VishalMistry
9th July 2011, 07:22
Does this help http://www.baanboard.com/baanboard/showthread.php?t=58443.
Hi Mr.Mark,
I tried this too. No luck.
Vishal
pillai.ganesh
11th May 2012, 13:39
Any body found the solution for this problem.
The name of my csv file also gets named as att2.csv
My customer wants a specific name for it.
Please Help
pillai.ganesh
15th May 2012, 09:46
Hi Mr.Mark,
I tried this too. No luck.
Vishal
Hi Vishal,
Is the issue of the attachment name getting changed at the recipient solved.
If you have found the solution for it then please update me of wat u did !!
Thanx in adv!
:)
dhruv_x0
15th May 2012, 10:50
As i read the script, might be there is the issue in the line as rtf format is specified in the mime attachment.
ret = cmf.setAttachmentMIME(attachment.ID,
"application/rtf")
Instead of "application/rtf" you should try "application/csv"
Regards
Anmol
ysovva
3rd June 2012, 16:42
Hello,
I have the same problem with renaming files in FP8. In addition the attachment is losing its extension. The extension is disappearing in the following checked cases: xls (application/excel), xlsx (application/excel), csv (checked for application/excel and application/csv). I tried to use both functions cmf.sendtoperson and cmf.send with same results.
Thx in adv.
Yurry
function long create.xml.header(
ref string sourcefile.list(,),
ref domain tcmail rec.list(),
domain tcmcs.s300m subject,
domain tcmcs.s999m body.file,
domain tfgld.user sender,
domain tcmail sender.mail)
{
domain tcdsca user.name
long message.ID, from.ID, to.ID, attachment.ID
long rec.list.size(2), file.list.size(2), dummy, i
for i = 1 to 2
rec.list.size(i) = 0
file.list.size(i) = 0
endfor
array.info(rec.list, dummy, rec.list.size)
array.info(sourcefile.list, dummy, file.list.size)
| subject()
message.ID = cmf.create()
ret.lng = cmf.setClass(message.ID, "CMF.NOTE")
ret.lng = cmf.setSubject(message.ID, subject)
| Set FROM recipient
if not tt.user(sender, user.name) then
user.name = tt.comp.desc()
endif
from.ID = cmf.createRecipient(message.ID, ttcmf.role.from)
ret.lng = cmf.setRecipientName(from.ID, trim$(user.name))
ret.lng = cmf.setRecipientAddress(from.ID, sender.mail)
ret.lng = cmf.setRecipientType(from.ID, "SMTP")
| Set TO recipient
if rec.list.size(2) then
for i = 1 to rec.list.size(2)
if not isspace(rec.list(1, i)) then
to.ID = cmf.createRecipient(message.ID, ttcmf.role.to)
| ret.lng = cmf.setRecipientName(to.ID, recipient.name)
ret.lng = cmf.setRecipientAddress(to.ID, trim$(rec.list(1, i)))
ret.lng = cmf.setRecipientType(to.ID, "SMTP")
ret.lng = cmf.setRecipientResponsibility(to.ID, "TRUE")
endif
endfor
endif
| Set attachment
if file.list.size(2) then
for i = 1 to file.list.size(2)
if not isspace(sourcefile.list(1, i)) then
attachment.ID = cmf.createAttachment(message.ID)
ret.lng = cmf.setAttachmentBody(attachment.ID, ttyeno.yes)
ret.lng = cmf.setAttachmentMIME(attachment.ID,
trim$(find.mimetype(sourcefile.list(1, i))))
ret.lng = cmf.setAttachmentFileName(attachment.ID,
sourcefile.list(1, i),
trim$(find.file.name(sourcefile.list(1, i))))
endif
endfor
endif
if not isspace(body.file) then
attachment.ID = cmf.createAttachment(message.ID)
ret.lng = cmf.setAttachmentBody(attachment.ID, ttyeno.yes)
ret.lng = cmf.setAttachmentMIME(attachment.ID, trim$(find.mimetype(body.file)))
ret.lng = cmf.setAttachmentFileName(attachment.ID, body.file)
endif
return(message.ID)
}
The XML result:
<CMF1>
<IDENTIFICATION MESSAGE-ID="0" CREATE-TIME="2012-06-03 13:33:05Z" CLASS="CMF.NOTE" SUBJECT="Report sent by ######" />
<DELIVERY/>
<RECIPIENTS>
<FROM NAME="#### - ### - ####" ADDRESS="######@######.###" TYPE="SMTP" />
<TO ADDRESS="####@#####.###" TYPE="SMTP" RESPONSIBILITY="TRUE" />
</RECIPIENTS>
<ATTACHMENTS>
<ATTACHMENT BODY="TRUE" MIME-TYPE="application/msexcel" LINK="mime.csv" FILENAME="mime.csv" />
<ATTACHMENT BODY="TRUE" MIME-="" TYPE="text/html" LINK="report_alert.htm" FILENAME="report_alert.htm" />
</ATTACHMENTS>
</CMF1>
myssk78
19th June 2012, 13:11
This is a known bug from Infor. They are working on it and will be releasing it sometime in the future.
adi28_rai
11th October 2012, 15:22
Hi Everyone,
The problem of the attachment name and extension getting changed is not a bug, you just need to do some modification as i see in your code to cope up with the problem. I also had struggled with this initially but after reading the help file again and again got the solution. I am pasting the attachment part of the script that you need to modify.
attachment.ID = cmf.createAttachment(message.ID)
ret = cmf.setAttachmentBody(attachment.ID,ttyeno.no)
ret = cmf.setAttachmentMIME(attachment.ID,"application/x-msexcel")
ret = cmf.setAttachmentFileName(attachment.ID,file.name,whwmd251.ownr&".xls")
Please check the Mime types as per the requirement of your file format.
This will surely help you i hope.
Can any one help me adding the body of the mail as i m done with the attachments but stuck with the mail's body part cant add that.
Thanks & Regards
adi28_rai
ysovva
12th October 2012, 21:49
Can any one help me adding the body of the mail as i m done with the attachments but stuck with the mail's body part cant add that.
adi28_rai
Hi,
you can try the follow part of the code:
if not isspace(body.file) then
attachment.ID = cmf.createAttachment(message.ID)
ret.lng = cmf.setAttachmentBody(attachment.ID, ttyeno.yes)
ret.lng = cmf.setAttachmentMIME(attachment.ID, "text/plain")
ret.lng = cmf.setAttachmentFileName(attachment.ID, body.file)
endif
adi28_rai
13th October 2012, 05:26
Hi Ysovva ,
Thnks for the reply but had my problem solved already, thanks anyways.
Regards
adi28_rai
layswan
11th March 2014, 10:50
Hi Ysovva ,
Thnks for the reply but had my problem solved already, thanks anyways.
Regards
adi28_rai
Hi adi28_rai,
How do u solved your mail's body part?
I am also facing the same problem.:(
Thanks!
adi28_rai
12th March 2014, 03:37
Hi Layswan,
In my case it was a silly mistake that i was doing i was giving the attachment section before the Body Section. Please check if your problem is also same.For your reference:
*****Body Part should be given First******
attachment.ID = cmf.createAttachment(message.ID)
ret = cmf.setAttachmentBody(attachment.ID,ttyeno.yes)
ret = cmf.setAttachmentMIME(attachment.ID,"text/plain")
ret = cmf.setAttachmentFileName(attachment.ID,file.name1)
*******Attachment only after Body Part********
if bp = 0 then
attachment.ID = cmf.createAttachment(message.ID)
ret = cmf.setAttachmentBody(attachment.ID,ttyeno.no)
ret = cmf.setAttachmentMIME(attachment.ID,"application/excel")
ret = cmf.setAttachmentFileName(attachment.ID,file.name,ownr.f&".xls")
endif
If you still cant please elobarate your problem a bit that would help.
Regards
adi28_rai