Solved

VB6 and CR 9   Emailing a .rpt

Posted on 2011-09-27
6
331 Views
Last Modified: 2012-05-12
Is it possible to run a crystal report using the crviewer in vb (already done) and email a copy of the report without having to export as a PDF first?
0
Comment
Question by:Jeff_Kingston
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 36710192
Without exporting to "something" I would say not you can not email a report simply from what is viewed on the screen.  If you already know how to make the pdf, that would be the best way to go.  You do not have to have the users interaction to do so.  If you have a button on screen, you could make the PDF and send the email in the background as long as you have a recipient and a sender address.
0
 

Author Comment

by:Jeff_Kingston
ID: 36710453
That sounds great, do you know where I could grab sample code?
0
 
LVL 14

Expert Comment

by:Brook Braswell
ID: 36710593
I use a tool called CodeStone to send emails with.

Public MySMTP As New SMTPClient
              Public MyPop3 As New POP3Client

              With New_Report
                   ' SHOULD YOU REQUIRE A PARAMETER FOR YOUR REPORT
                   .ParameterFields(1).AddCurrentValue Str(YOUR PARAMETER)
                   .ExportOptions.PDFExportAllPages = True
                   .ExportOptions.DestinationType = crEDTDiskFile
                   .ExportOptions.DiskFileName = "YourFilePath\" & sYourFileName & ".pdf"
                   .ExportOptions.FormatType = crEFTPortableDocFormat
                   .DisplayProgressDialog = False
                   .Export False
              End With

              Dim MyMsg As New CSMAILLib.MESSAGE

              MyMsg.Subject = sSubject
              MyMsg.To(1) = sRecipient
              MyMsg.From(1) = sSender
              ' SHOULD YOU HAVE CC OR BCC IN YOUR MAIL
              MyMsg.CC(1) = sCC  
              MyMsg.bCC(1) = sBCC
              Dim sSection As CSMAILLib.Section
              MyMsg.Sections(1).Body = Trim(sBody)
              Set sSection = MyMsg.Sections.Add
              sSection.AttachBodyFromFile ("YourFilePath\" & sYourFileName & ".pdf")
              ' for some exchange servers the user and pass are not required
              MySMTP.ConnectESMTP sSMTPServer, "", "", "", sSMTPPort  ' For Exchange 2010
              ' else use a user pass for a mail server
              MySMTP.ConnectESMTP sSMTPServer, sPOP3User, sPOP3Pass, sPop3Login, sSMTPPort
              MySMTP.SendMessage MyMsg
              MySMTP.Close

              ' when you are done it does not hurt to kill the file afterwards to keep things clean
              Kill ("YourFilePath\" & sYourFileName & ".pdf")

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:Brook Braswell
ID: 36710898
BTW - here is a link to the for the email tool
http://www.codestone.co.uk/
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 36713068
If you are using  MAPI mail system like Exchange you can load the MAPI export dlls and mail it directly from the viewer.  It goes as an attachment and the attachment can be a PDF.

Code is similar to the above except you choose the MAPI option and attachment format.

mlmcc
0
 

Author Closing Comment

by:Jeff_Kingston
ID: 36716160
Thanks for the direction.. seems pretty straight forward
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now