-
Dear All...
I would like to ask about the combination of crystal report and email system.
Here goes the problem.
I've a report designed at crystal report 7.0.
And if the user click print the report, my program will automatically make the report to be an attachment, and will automatically send to an email address.
Can I do that in VB 6.0 ??? If I can, HOW ???
Cheers,
Wen Lie
-
Save it to a file
Wen,
You can, from VB, select the destination of the report.
REPORT.DESTINATION = 2 will send the report to a file instead of to the printer. You will also need to set the REPORT.PRINTFILENAME property and the type of file it is to print to - see the PrintFileType property to do that.
I'm using Crystal 8 but I can't believe they'd bodge around with such fundamental properties.
-
Thx... but...
Well... anakim...
Thx.. for your suggestion...
But, I already know about it....
I know how to print to file.
But, now, what I need is...
Whenever the user click print button at crystal report,
my VB program will automatically print the report to printer, and at the same time, will create a file, and then my VB program will automatically send the file created to an email address (the spesific email address).
do you know how to do it anakim ???
Thx,
nd Cheers,
Wen Lie
-
Right I know what you're getting at now!
How about putting some code in the crystal viewers 'PrintButtonClicked' event to dump the report out to a file.
If you have outlook you could use the Outlook Object library (msoutl9.olb) to send the email....
Set oOutlook = CreateObject("Outlook.Application")
Set oMailItem = myOlApp.CreateItem(olMailItem)
Set oAttachment = oMailItem.Attachments
oAttachment.Add "C:\Reports\Rep1.rpt", _
olByValue, 1, "A Report"
oMailItem.Body = "Here's your report"
oMailItem.To = "[email protected]"
oMailItem.Send
If you're not using outlook then you could always start :p! Sorry, we use outlook so there's been no need to look for alternatives.
Hope that's a little more useful than the previous cak I posted.
-
PS
Erm hope you hadn't got bored of waiting for a reply, neglected to check my email for a couple of days.
Ooops!
-
What the hell is Crystal Report???
I got it with VB and I don't know what the hell it does!
-
Crystal's just a tool which enables you to produce professional looking reports. It's quite easy to link it to a DB and extract a load of info, while changing the selection parameters at run time.
If you use Access as the DB then probably you are best using Access' reports but if using an industry DB (Oracle/Informix) then it's very useful.
Have a look at Seagate's site if you want more info....
http://www.seagatesoftware.com/products/crystalreports/
-
Thx...
Thx... anakim...
I will try the code...
nd will contact you, if I've got trouble with the code.
Cheers,
Wen Lie
-
You can also use the MAPI controls that comes with VB.
With them you can send e-mail with any MAPI enabled e-mail client.
Just add them to a form and use code simular to this:
Code:
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.Compose
MAPIMessages1.RecipAddress = "[email protected]"
MAPIMessages1.RecipDisplayName = "Someone AnyBody"
MAPIMessages1.MsgSubject = "Report"
MAPIMessages1.MsgNoteText = "The report is attached"
MAPIMessages1.AttachmentPathName = "C:\ThePath\TheReportFileName"
MAPIMessages1.Send
MAPISession1.SignOff
Good luck!