Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Thursday, June 19, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: How to save a PDF report as an attachment to email
Mary
Posts: 17
 
How to save a PDF report as an attachment to emailYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Sep 06 10:01 AM
fiogf49gjkf0d
Hi,

I am using v6.1 and need to email a report as an attachment in the code. How to save a PDF report (CrystalReport) to somewhere, and then add this saved report as an attachment to the email? Or is there other way to do this?

Thanks,
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: How to save a PDF report as an attachment to emailYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Sep 06 1:10 PM
fiogf49gjkf0d
In v6.1 it is doable, although not a trivial task. You have to either extract the report from the plugin table's blob for the report plugin, or distribute the report to the SLX folders via a sync action or other. Once extracted you use Crystal RDC to set the connection info for the report (so it can connect to the current database) run the report & save as a PDF. Then Outlook automation to attach to a new mail window.

In 6.2.1 (IIRC) there is a new function:

Application.BasicFunctions.GetCrystalReport


Which gives you an already connected RDC object referencing a report that was extracted from the plugin table for you. Much easier.

You can get the Crystal RDC docs from this site here: http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=29
[Reply][Quote]
Mary
Posts: 17
 
Re: How to save a PDF report as an attachment to emailYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Sep 06 2:08 PM
fiogf49gjkf0d
Thanks Ryan for your reply. It sounds quite complex. I still cannot figure out how to achieve this. I appreciate if you could explain in more details.

Thanks a lot

[Reply][Quote]
John Foster
Posts: 18
 
Re: How to save a PDF report as an attachment to emailYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 27 Sep 06 12:24 AM
fiogf49gjkf0d
Can you wait until 7.0. I'm working on a .NET extension to do just what you are asking. I do have a version for 6.x, but as Ryan says, you've got to deal with distributing files...
[Reply][Quote]
Mark Richardson
Posts: 25
 
Re: How to save a PDF report as an attachment to emailYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Jul 07 3:23 AM
Hi Mary,

The steps are relatively simple - i've given the essentials below - you'll also notice the Include Scripts you'll need.
There are a couple of nusances - namely the Outlook pop-up 'There is a program trying to access you mailbox' type thing (PLEASE does somebody know how to overcome this - embarrassingly, I was browsing and briefly read something along the lines of "if the code is written poorly..." !!! - Is there a way around this??
In my case Mary - i've had to use a (free) utility to overcome this - you can get this at http://www.contextmagic.com/express-clickyes/ (Choose the free version but READ the differences twixt the 2!) If you have standardly decent Network infrastructure you shouldn't have to worry.

You'll also see this script relies on Network Use (Remotes you'd have to have a local copy of the 'Quote.rpt' - this could be done in many ways)

Anyway - enough of the blabbing.... Script follows:

'Including Script - System:SLX_Common
'Including Script - System:SLX_DoOutLook_AS
option explicit
Sub ReportToPDFtoEmail

Dim filesys, strpath, strReportFile, strReportName, CRXReport, objRDC,soid
soid = ***** this is where you'd get your (for instance) SalesOrderID ***
set filesys = CreateObject("Scripting.FileSystemObject")
strpath = "\\srvapps01\synclogs\Quotes\"
If Not filesys.FolderExists(strpath) Then
filesys.CreateFolder(strpath)
End If

strReportFile = strpath & soid & ".pdf"
If (filesys.FileExists(strReportFile)) Then
filesys.DeleteFile(strReportFile)
End If

Set filesys = Nothing
Set objRDC = CreateObject("CrystalRuntime.Application")
' I have chosen to put an accessible report (for Network users) into the folder location below
Set CRXReport = objRDC.OpenReport("\\srvapps01\synclogs\quote.rpt")

CRXReport.RecordSelectionFormula = "{SALESORDER.SALESORDERID} = '" & soid & "'" ' <- soid being my SalesOrderID (or whatever!)
CRXReport.ExportOptions.DestinationType = 1
CRXReport.ExportOptions.DiskFileName = strReportFile
CRXReport.ExportOptions.FormatType = 31
CRXReport.Export False

Set CRXReport = Nothing
Set objRDC = Nothing
'===================================================
Dim oOApp
Dim oOMail
Dim olByValue
'Dim oInsp
Set oOApp = CreateObject("Outlook.Application")
Set oOMail = oOApp.CreateItem(olMailItem)
With oOMail
.To = "mark.richardson@steljes.co.uk"
.Subject = "Quote: " & soid
.Body = "Heres your Quote"
.Attachments.Add strpath & soid & ".pdf", olByValue, 1
' Uncomment one of the below lines to choose whether to display the email to the user or to just automatically send
'.Display
'.Send
End With
Set oOApp = Nothing
Set oOMail = Nothing
End Sub
[Reply][Quote]
Darron Cockram
Posts: 8
 
Re: How to save a PDF report as an attachment to emailYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Jul 07 5:53 AM
Hi Mark,

I did something similar to this a little while back but to actually create the e-mail message I used the Application.BasicFunctions.QueMessage function. You don't have as much control as you do using the Outlook object model (e.g. you can't send the e-mail from code) this but it does create the message without the annoying 'There is a program trying to access you mailbox' message and you don't need to install any additional software.

Something along the lines of:

Application.BasicFunctions.QueMessage "mark.richardson@steljes.co.uk", "", "", "Quote: " & soid, "Heres your Quote", strpath & soid & ".pdf"

should do the trick.

Also to get around the problem of network paths for remotes I added the report to SalesLogix in the normal manner and the used Application.BasicFunctions.GetCrystalReport to return the report i.e.

Set CRXReport = Application.BasicFunctions.GetCrystalReport("Opportunity:Quote Template")

Other than that the rest of the report code to set export options and filters is pretty much the same as yours

Hope this helps.
Darron
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/19/2025 4:25:07 PM