Member_2_1242703
asked on
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.Compose
MAPIMessages1.RecipDisplay Name = "Blow,Joe"
MAPIMessages1.MsgSubject = "Subject of Email"
MAPIMessages1.MsgNoteText = "Message Text"
MAPIMessages1.ResolveName
MAPIMessages1.Send
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.
Here's the code for the button:
MAPIMessages1.Compose
MAPIMessages1.RecipDisplay
MAPIMessages1.MsgSubject = "Subject of Email"
MAPIMessages1.MsgNoteText = "Message Text"
MAPIMessages1.ResolveName
MAPIMessages1.Send
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.
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.
ASKER
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?
mlmcc
mlmcc
ASKER
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
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
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:\MyRep orts\MyRpo rt.rpt", 1)
crRpt.MorePrintEngineError Messages = False
crRpt.EnableParameterPromp ting = False
crRpt.DisplayProgressDialo g = False
crRpt.DiscardSavedData
'
' Set export options
'
crRpt.ExportOptions.Destin ationType = crEDTEMailMAPI
crRpt.ExportOptions.MailTo List = txtMailAddress
crRpt.ExportOptions.MailSu bject = txtMailSubject
crRpt.ExportOptions.MailMe ssage = txtMailMessage
crRpt.ExportOptions.Format Type = crEFTWordForWindows
crRpt.Export False
mlmcc
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:\MyRep
crRpt.MorePrintEngineError
crRpt.EnableParameterPromp
crRpt.DisplayProgressDialo
crRpt.DiscardSavedData
'
' Set export options
'
crRpt.ExportOptions.Destin
crRpt.ExportOptions.MailTo
crRpt.ExportOptions.MailSu
crRpt.ExportOptions.MailMe
crRpt.ExportOptions.Format
crRpt.Export False
mlmcc