Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

E-mailing Reports from V11 Server

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    E-mailing Reports from V11 Server

    I have been trying to get this code to work on my server for three days. It works just fine on on my localhost, it sends the email, filtered correctly, with the attachement. Once I publish it on the server, the code runs, sends the e-mail, but does not send an attachment.

    In an attempt to fix the issue, I upgraded to A5V11 from V10, with no success. I have taken multiple troubleshooting steps including reinstalling V11, changing the file name, and changing UAC on the server I've published the site to; all with no success. If you can help me run through some troubleshooting steps I will teach you to balance a spoon on your nose.

    I know. How cool is that? Fair trade imo.



    filter = "orderid=" + e.lastIdentityValue
    body = <<%a%
    Your Order Has Been Placed
    %a%
    reportlayout = "BranchOrder@C:\A5Webroot\specgasv2\Default\specgasv2.alb"
    message.message = body
    message.to = a5ws_getcurrentuser()
    message.subject = "Order"
    message.attachments = report.SaveAs(reportlayout,"PDF",filter,"","Order"+e.lastIdentityValue+".pdf",.f.)
    email_send2(message,"RBO", .T., .F.)

    #2
    Re: E-mailing Reports from V11 Server

    Hi Kate,

    I am trying to figure out how to do exactly what you are doing, maybe we can help each other. I can already balance a spatula on my nose so I'm not really interested in the spoon trick.

    In what event are you putting this code?
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

    Comment


      #3
      Re: E-mailing Reports from V11 Server

      Woah, spatula? Here I thought I had something cool to contribute!


      So, on the AfterInsertRecord event I placed my code.

      I have a grid which allows users to create one record at a time. When they click "Submit" the event fires. The record is written to my SQL backend, and the logged in user receives an e-mail with and attached report of the order they just placed; filtered by the order number as the PK(last id value). The strangest thing is, that I have a "print" button for that same report on a different grid, and it works with no problem on the server.

      I'm thinking there's something wrong with my filename or with permissions on saving to a folder on a server. Maybe the report.saveas needs a different [insert magic answer here] on the server side versus a local publication.

      I'm stuck because I don't receive an error, and no file saves to the server.


      I suppose I also forgot to show my variable declarations:

      dim message as P
      dim filter as C
      dim reportlayout as C
      dim reportname as C


      I have little other talents to offer, except perhaps my uncanny ability to ensure the loss of any sports teams for whom I am cheering. Seems quite unhelpful though.

      Comment


        #4
        Re: E-mailing Reports from V11 Server

        reportlayout = "BranchOrder@C:\A5Webroot\specgasv2\Default\specgasv2.alb"
        you should be addressing the alias path - also you are addressing the A5Webroot your report exists in the database on the server not the webroot.. just some hints.
        Insanity: doing the same thing over and over again and expecting different results.
        Albert Einstein, (attributed)
        US (German-born) physicist (1879 - 1955)

        Comment


          #5
          Re: E-mailing Reports from V11 Server

          This works for me in an ajaxcallback from an action button.
          Code:
          function xbSendEmail as c (e as p)
          
          dim pm as p
          pm.to = e._currentRowDataNew.email
          pm.from_alias = "My Company"
          pm.subject = "Estimate"
          pm.attachments = e._currentRowDataNew.attachment
          pm.Html_Message = <<%html%
          Yada Yada Yada, Blah Blah Blah
          %html%
          
          email_send2(pm)
          
          xbSendEmail = "alert('Email has been sent');"
          end function
          This requires that i save the report to disk, which I do anyhow, and then save the filename with the path to a field in my table for the grid I am doing the callback from. I can then retrieve the data via the e._currentRowDataNew object.
          Since this callback is running on the server and the file is saved on the server this works OK.
          I tried using the action javascript email builder in V11 but could not get the attachments to work. I suspect because the javascript is running on the client and the file is saved on the server. Maybe that is the same issue you are having. Especially since it runs on the localhost.
          I would like to get away from saving the file and filename and doing it more directly like you are. Maybe I can do it all in one callback.
          I will try your style tomorrow and see what I can come up with.
          Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

          Comment


            #6
            Re: E-mailing Reports from V11 Server

            I have this working for me.
            What I am doing is running the report to the session.session_folder directory. then pointing the attachments parameter to that file. This way the file is destroyed at the end of the session.
            For you:
            Code:
            cFileName = session.session_folder+"\Order"+e.lastIdentityValue+".pdf"
            cFileName = report.SaveAs(reportlayout,"PDF",filter,"",cFileName,.f.)
            message.attachments = cFileName
            Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

            Comment


              #7
              Re: E-mailing Reports from V11 Server

              Pete-

              I am pretty sure it's not an issue with my alias reference, but I wanted to be sure. And, heck, I may still be wrong. However I had already tried every possible combination of the Path Alias I could come up with before posting here. I am attaching the three other setups I have used to get this to work besides the one posted above. On the attached attempts I changed my code to the following:


              dim message as P
              dim filter as C
              dim reportlayout as C
              dim reportname as C
              filter = "orderid=" + e.lastIdentityValue
              body = <<%a%
              Your Order Has Been Placed
              %a%
              reportlayout = "BranchOrder@[PathAlias.ADB_Path]\specgasv2.alb"
              message.message = body
              message.to = a5ws_getcurrentuser()
              message.subject = "Order"
              message.attachments = report.SaveAs(reportlayout,"PDF",filter,"","Order"+e.lastIdentityValue+".pdf",.f.)
              email_send2(message,"RBO", .T., .F.)


              In addition, I don't think it was an issue with the server finding the report, as all of these returned an error which states it could not find the report. The issue I'm having is that I'm not receiving an error, but I am receiving the-mail without the attachment.

              Frank,

              I thought I read somewhere that we can't use session.session_folder on V11? Do you have this working for you on V11? I'll give that a go as well.


              Thank you all!

              Setup.zip

              Comment


                #8
                Re: E-mailing Reports from V11 Server

                Frank,

                Your way worked. Unfortunately, my nose-spoon skills are not as valuable as I had hoped. Thank you both sincerely for your help! I'm so happy to finally be moving on from this! Sheesh.


                = Kate

                Comment


                  #9
                  Re: E-mailing Reports from V11 Server

                  For anyone else hoping to solve this problem; here is my final code:

                  reportlayout = "BranchOrder@C:\A5Webroot\specgasv2\Default\specgasv2.alb"
                  cFileName = session.session_folder+"\Order"+e.lastIdentityValue+".pdf"
                  cFileName = report.SaveAs(reportlayout,"PDF",filter,"",cFileName,.f.)
                  message.attachments = cFileName
                  filter = "orderid=" + e.lastIdentityValue
                  body = <<%a%
                  Your Order Has Been Placed
                  %a%
                  message.message = body
                  message.to = a5ws_getcurrentuser()
                  message.subject = "Order"
                  'message.attachments = report.SaveAs(reportlayout,"PDF",filter,"","Order"+e.lastIdentityValue+".pdf",.f.)
                  email_send2(message,"RBO", .T., .F.)


                  Keywords for search:

                  mail report attachment email onsubmit submit order

                  Comment


                    #10
                    Re: E-mailing Reports from V11 Server

                    hi, i have been using this to save docs to file from the desktop but am now moving to the web and am struggling to get this to work.

                    this works on on the desk top, i see you are using session.session_folder - how do i refer session_folder to the folder in my webroot which holds the folders that my documents are to be saved to?

                    Code:
                    dim vfolder as c
                    dim vcfile as c
                    dim vdoc as c
                    dim vclient as c
                    dim vfilter as c
                    dim tbl as P
                    dim tbl2 as P
                    dim vroot as c
                    dim session.fileloc as c
                    
                    
                     ' generate idd and save to file
                    vclient=alltrim(session.clientsurname)+alltrim(session.caseref)
                    [COLOR="#FF0000"]vfolder=trim("C:\A5Webroot\DMC\ClientFiles")[/COLOR]
                    vcfile=vfolder+"\\"+vclient
                    vdoc=vcfile+"\\"+"Comp_IDD_"+dtoc(date(),"1-")+".pdf"
                    vroot="http://www.secureclientservices.co.uk:8082/dmc/clientfiles"+"/"+vclient+"/"+"Comp_IDD_"+dtoc(date(),"1-")+".pdf"
                    
                    vfilter = "idd->caseref = "+quote(session.caseref)
                    
                    query.filter = vfilter
                    query.order = ""
                    
                    report.saveas("IDD@[PathAlias.ADB_Path]\idd.dbf", "PDF", query.filter, "",vdoc, .F.)
                    
                    
                    ' add note to confirm idd created and saved to file
                    
                    tbl = table.open("[PathAlias.ADB_Path]\tnotes.dbf")
                    	
                    	tbl.enter_begin()
                    	tbl.Caseref = session.caseref
                    	tbl.Noteaddedby = session.employeename
                    	tbl.notedate=date()
                    	tbl.notecategory="Compliance"
                    	tbl.noteinfo="IDD Created"
                    	tbl.Notereason="IDD Generated and saved to file"
                    	tbl.note_publish = "yes"
                    	tbl.enter_end(.T.)
                    
                    tbl.close()
                    
                    ' create document link for IDD to allow client download
                    
                    tbl2 = table.open("[PathAlias.ADB_Path]\target.dbf")
                    
                    tbl2.enter_begin(.T.)
                    tbl2.caseref= session.caseref
                    tbl2.Targetname="Initial Disclosure Document"
                    tbl2.Target=vroot
                    tbl2.date_created = date()
                    tbl2.publish_doc = "Yes"
                    tbl2.enter_end(.T.)
                    
                    tbl2.close()
                    thanks

                    Comment


                      #11
                      Re: E-mailing Reports from V11 Server

                      This works for me.

                      Code:
                      	dim pOptions as p
                      	DIM myargs as SQL::arguments
                      	dim lcReportName as c
                      	dim lcFileName as c
                      	dim lcDirectory as c
                      
                      	myargs.add("Argument Name",Value)
                      	pOptions.filter = "Field = :Argument Name"
                      	lcReportName = "Report Name here"
                      	
                      	lcDirectory = "Directory Path here"
                      	lcFileName = lcDirectory + chr(92) + "FileName here"+".pdf"
                      	
                      	report.saveas(lcReportName,"PDF","","", lcFileName,.F.,.F.,myargs,pOptions)
                      Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                      Comment

                      Working...
                      X