java - How to send mail with attachment in GWT? -
i know if there way send email attachment file gwt. managed send simple email without attachment, having problem when try add file.
the problem "fileupload" don't give fullpath of file
it seems safety reasons impossible retrieve full path of file client. there way keeping logical server in gwt client?
my code
client side:
fileupload upload = new fileupload(); // cannot retrieve full path string fileattachment = upload.getname();
server side:
public void sendmail(string sender, string[] recipients, string subject, string message, string fileattachment) { try { ...(init) // part 2 attachment messagebodypart = new mimebodypart(); // => fileattachment need full path datasource source = new filedatasource(fileattachment); messagebodypart.setdatahandler( new datahandler(source)); messagebodypart.setfilename(fileattachment); multipart.addbodypart(messagebodypart); // put parts in message msg.setcontent(multipart); // send transport.send(msg); }
thanks help
you have upload file server.
the easiest way in gwt put fileupload
(and form input widgets) in formpanel
; has drawback of making error handling (and response handling server) more difficult though.
an alternative, in recent browsers, file
object (not java.io.file
, js object) out of fileupload
, upload using xmlhttprequest
(possibly coupled formdata
send other form values). in gwt, means using jsni (it might possible use elemental
library too), , know innards of you're doing.
in case, won't able use gwt-rpc talk server and send file @ same time.
Comments
Post a Comment