Solved

VB6 and CR 9   Emailing a .rpt

Posted on 2011-09-27
6
329 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

20 Experts available now in Live!

Get 1:1 Help Now