Skip to Content
0
Oct 10, 2012 at 10:30 PM

VB6 export crystal xi to PDF and attach to email using MAPI

847 Views

I want to

1. Export a crystal report to PDF

2. Attach this file to a new email.

I can do the first part but I'm getting an error on the second part Error 32012 Failure on Opening Attachment. My code is:

[Code]

Dim CApp As New CRAXDRT.Application

Dim CReport As CRAXDRT.Report

Dim CRExportOptions As Object

expFile = "C:\Report\rep1.rpt"

Set CReport = CApp.OpenReport(expFile)

FileLoca = Left(expFile, Len(expFile) - 3) & "pdf"

CReport.EnableParameterPrompting = False

CReport.DiscardSavedData

CReport.ReadRecords

Set CRExportOptions = CReport.ExportOptions

CRExportOptions.FormatType = crEFTPortableDocFormat '

CRExportOptions.DestinationType = crEDTDiskFile

CRExportOptions.DiskFileName = FileLoca

CReport.DisplayProgressDialog = False

CReport.Export False

Set CRExportOptions = Nothing

MAPISession1.SignOn

With Me.MAPIMessages1

.SessionID = MAPISession1.SessionID

.MsgIndex = -1

.Compose

.AddressEditFieldCount = 1

.MsgNoteText = strmessage

.AttachmentPosition = 0

.AttachmentName = "" & FileLoca & ""

.AttachmentPathName = "" & FileLoca & ""

.AttachmentType = mapEOLE

.Send True

End With

MAPISession1.SignOff[/Code]