Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Question on Attachements for Email

    Isomorphic,

    We have a requirement where a user is able to send an email with an attached excel sheet of the contents of a list grid and a snapshot of a graph.

    I am able to export the listgrid as an excel sheet using exportData. I am also able to send emails using the MailMessage class. But I cant seem to find a way to add attachments to the email.

    Is there a way in which I can attach an exported Excel sheet to the email? Is it also possible to export the graph as an image which i can attach to the email?

    Thanks
    Last edited by sabre_chandan; 27 Mar 2012, 00:43.

    #2
    In 3.1d, you can use RPCManager.exportContent() to export a chart as a .pdf on all supported browsers except IE8 and earlier. The server-side JavaDoc explains how to get this .pdf as an in-memory Java object in server code; there's currently not a way to get it as an image file, but a .pdf might also work for you, or you might use a technique that converts a .pdf to an image.

    You can use dsRequest.exportToFilesystem to cause an Excel export to target a file instead of being streamed back to the browser.

    Our mail APIs don't currently handle attachments, but this is relatively straightforward with direct use of javax.mail.

    Comment


      #3
      Is there anyway we can interrupt the Excel Export to the file system and instead attach the java object to the email. Since saving the excel sheet on the server filesystem doesn't seem like an option for us.
      Last edited by sabre_chandan; 27 Mar 2012, 22:07.

      Comment


        #4
        We plan to add an API in 3.1d dsResponse.exportTo(outputStream) that would allow you to capture the export stream. It will probably be in before the end of next week.

        Comment


          #5
          Hi

          I have managed to create the basic email functionality to some extent. I am able to export the chart as a pdf and capture the java object and attach it to the mail. Using javax.mail im able to send a mail with attachements.

          Im still having problems with attaching the data in my listgrid to the email.
          1) Im trying to get the listgrid data along with any sort of client formatting.We are using data paging for the listgrid. What I have noticed is that if I try to export a listgrid with a lot of records to a pdf (using RPC.exportContent) or to csv (using listgrid.exportClientData) I get the following error and the export fails
          Code:
           ERROR IDACall - Top-level servlet error: 
          java.lang.IllegalStateException: Form too large2212849>200000
          	at org.mortbay.jetty.Request.extractParameters(Request.java:1404)
          	at org.mortbay.jetty.Request.getParameter(Request.java:749)
          	at com.isomorphic.rpc.RPCManager.initLog(RPCManager.java:329)
          	at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:284)
          	at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:271)
          	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:116)
          	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
          	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
          	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
          	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
          	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
          	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
          	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
          	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
          	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
          	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
          	at org.mortbay.jetty.Server.handle(Server.java:324)
          	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
          	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
          	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
          	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
          	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
          	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
          	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
          2) Is there anyway that I can specify a DMI during the listgrid export using exportClientData?
          I tried doing something like
          dsRequest.setDataSource("email");
          dsRequest.setOperationId("sendEmail");
          dataGrid.exportClientData(dsRequest);
          but my DMI does not get executed.

          Is this the right approach?

          SmartGWT version: SC_SNAPSHOT-2012-02-24_v8.2p/Enterprise Deployment 2012-02-24

          Comment


            #6
            1. This error is coming from Jetty, not SmartGWT. It looks like you need to set a higher limit on the maximum HTTP POST that Jetty will allow.

            2. What would you do in a DMI for exportClientData? By design the format sent to the server is not documented - is the idea to capture the generated Excel doc?

            Comment


              #7
              Yes the main idea is to capture the generated Excel doc object. I guess exportClientData will not help me. What do you suggest to get an excel object of all the client formatted data? What approach do you feel I should take?

              Comment


                #8
                setExportTo() lets you get Excel documents generated by exportData() but not exportClientData(). So one approach would be to add logic to your DataSource to optionally return already-formatted values, which would then work with exportData().

                We also plan to add a feature to allow exportClientData() to go through the normal DataSource processing flow for just this kind of use case, no ETA on that (unless you sponsor it).

                Comment

                Working...
                X