Using MAPI to send report

I have an application that pulls up a report using CRViewer. On the form that contains the CRViewer I also have a button.
Here's the code for the button:

MAPIMessages1.RecipDisplayName = "Blow,Joe"
MAPIMessages1.MsgSubject = "Subject of Email"
MAPIMessages1.MsgNoteText = "Message Text"

The code above works fine. However, I want the "Message Text" to be something else. I want to email the contents of the report as the MAPIMessages1.MsgNoteText. How do I do this? Or, is there another way to email this report with Outlook? Thanks.
Mike MillerSoftware EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
I'm guessing that CRViewer is a portion of Crystal Reports.  If Crystal Reports can output/save the report in plain text, HTML, or RTF format, then you can set the body of the message to be the contents of the report.  Otherwise, the best you're going to be able to do is to attach the report as a file.
Mike MillerSoftware EngineerAuthor Commented:
Yes CRViewer is a VB component used to show a report during runtime. And it does have the ability to output the report in all 3 methods.
How about using the export button on the viewer to export to MAPI?

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mike MillerSoftware EngineerAuthor Commented:
That's what I was thinking. Or using export to save the report as temp text file and sending that. Either way, I can't figure out how to change the code for the export button.
What about sending the report as an attachment?

You can do this simply by exporting the data from the CRViewer to a file and then attach the file to the mail and send via MAPI

Mike MillerSoftware EngineerAuthor Commented:
That would be fine. I want to be able to do this by clicking one command button though. I do not want the user to have to export, then attach. I don't know how to do it any other way.
David LeeCommented:
If you know how to export, then I can give you the code to attach.  Or, if you know how to export as HTML, I'll give you the code to make the exported report the message body.
This code will export report into PDF format, you can use many other formats too. Just specify the FortmatType property

Report.ExportOptions.DestinationType = crEDTDiskFile
Report.ExportOptions.FormatType = crEFTPortableDocFormat
Report.ExportOptions.PDFExportAllPages = True

Report.ExportOptions.DiskFileName = **YouFilePath**
'Export to PDF Format, setting False prevents the Export dialog window from showing

Report.Export False


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Using the export button will require the users to select Mapi and several other options.

Here is the code to mail a report
Option Explicit
    Private crApp As CRAXDRT.Application
    Private crRpt As CRAXDRT.Report

'   Open report
    Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport("C:\MyReports\MyRport.rpt", 1)
    crRpt.MorePrintEngineErrorMessages = False
    crRpt.EnableParameterPrompting = False
    crRpt.DisplayProgressDialog = False
'   Set export options
        crRpt.ExportOptions.DestinationType = crEDTEMailMAPI
        crRpt.ExportOptions.MailToList = txtMailAddress
        crRpt.ExportOptions.MailSubject = txtMailSubject
        crRpt.ExportOptions.MailMessage = txtMailMessage
        crRpt.ExportOptions.FormatType = crEFTWordForWindows

        crRpt.Export False

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.