[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Using MAPI to send report

Posted on 2004-10-25
9
Medium Priority
?
274 Views
Last Modified: 2012-05-05
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.RecipDisplayName = "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.
0
Comment
Question by:Mike Miller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 12401913
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.
0
 

Author Comment

by:Mike Miller
ID: 12402066
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.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12402345
How about using the export button on the viewer to export to MAPI?

mlmcc
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Mike Miller
ID: 12402383
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.
0
 
LVL 4

Expert Comment

by:AjithJose
ID: 12404492
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



 
0
 

Author Comment

by:Mike Miller
ID: 12404515
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.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12405146
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.
0
 
LVL 4

Accepted Solution

by:
AjithJose earned 2000 total points
ID: 12407605
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

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12407651
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
    crRpt.DiscardSavedData
'
'   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


mlmcc
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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