Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export DestinationType = 2 - EmailOption

Status
Not open for further replies.

week

MIS
Feb 14, 2001
118
0
0
US
I am trying to email a report as an Excel Attachment file. My code is as follows:

objExportOptions.DestinationType = 2 'crEDTEMailAMPI
objExportOptions.MailToList = vAddress
objExportOptions.MailSubject = "Report file requested from the system"
objExportOptions.MailMessage = "Here is the document..."
objExportOptions.FormatType = 21

It looks like it should work but it errors out at DestinationType = 2 saying the object doesn't support this function. I know for a fact that it works fine with DestinationType = 1 (DiskFileExport) and I believe Crystal 8.5 supports DestinationType = 2. So, why is it bombing on me with 2?? Does anyone have any idea?

Thanks a bunch!!
 
Found out destinationtype is not really the problem. It actually is fine. But I am having trouble with some other object and don't know which and what could be missing. My code is as follows:

objExportOptions.MailToList = vAddress
objExportOptions.MailSubject = "Report file requested from the system"
objExportOptions.MailMessage = "Here is the document..."
objExportOptions.FormatType = 21
objExportOptions.DestinationType = 2
objExportOptions.PrintFileName = sReportFilesPath & "\EmailExcel\" & cvDocumentGUID & ".xls"
objExportOptions.Action = 1
objReport.Export False

Not sure about PrintFileName. What's that really for?
Do I need objReport.Export if I have objExportOptions.Action?

I don't see anything during debugging this steps due to the environment set up. Any insights would be helpful...getting pretty frustrated here.

Thanks.
 
Week,
Did you try to turn on "Break on all errors" in VB (Tools\Options\General) and remove any "On Error Resume" statements from the procedure? Step through the code and it will "blow up" where ever the error is occuring.

I had a similar problem, where the email would not be sent. I found that if the email address you are trying to send to is not in your address book, there is a runtime error. The email is still sent if you use Microsoft Outlook for the email client, I am using Netscape. I have to trap for the error and send the user back an error message to add the address to their address book.

Below is a copy of my code.

Jeff



Private Sub cmdProcess_Click()
Set Rep = crxApplication.OpenReport(DENReportPath & "RPT335D.RPT", 1)

Rep.ReportTitle = Me.Caption

Rep.ReportComments = Rep.ReportComments & "Date Range: " _
& txtStartDate.text & " - " & txtEndDate.text

'build selection formula based on date range
D1 = SQLdate(txtStartDate.text) '*** Convert date to SQL format
D2 = SQLdate(txtEndDate.text)

SF = "{CCO_MST_DATE.MST_DATE} IN DATE(" & D1 & ") TO DATE(" & D2 & ")"
Comments = " All Departments All Items"

Rep.Database.LogOnServer "P2SODBC.DLL", "ATICTS" '*** Log into database
If Err Then
If Err <> &quot;-2147192184&quot; Then 'Cancel login
msg = &quot;Unable to establish connection, error = &quot; & Err & &quot; - &quot; & Err.Description
Call MsgBox(msg, StyleEx, ATICTS)
End If
Err.Clear
Hourglass False
Exit Sub
End If

SF = Rep.RecordSelectionFormula '*** Set base formula, changes on dept

For X = 1 To RSFRec.brExtract(2).brDCount(VM) '*** Loop through departments
Dpt = DeptNo '*** Dept Number

Rep.RecordSelectionFormula = SF & &quot; and {CCO.MST_DEPT_ALL} = '&quot; _
& Dpt & &quot;'&quot; '*** Add dept as part of selection

Rep.ExportOptions.DestinationType = crEDTEMailMAPI
Rep.ExportOptions.FormatType = crEFTExactRichText
Rep.ExportOptions.MailSubject = &quot;Consumable Usage Report By Date Range&quot;
Rep.ExportOptions.MailMessage = &quot;For Department: &quot; & Dpt

ToString = RSFRec.brExtractStr(4, X) '*** Dept Head to email
CCString = RSFRec.brExtractStr(4, X) '*** Send CC to this person

MainEmail = &quot;&quot;
CCMail = &quot;&quot;
MainEmail = ToString
CCMail = CCString

Rep.ExportOptions.MailToList = &quot;&quot; '*** Clear out previous recipients
Rep.ExportOptions.MailToList = MainEmail
Rep.ExportOptions.MailCcList = CCMail

If Rep.ExportOptions.MailToList <> &quot;&quot; Then '*** Only export if email address
Rep.Export (False)
End If
Next X
 
Thanks a lot for your suggestion, dataent. I decided to take a different route. Got fed up messing with Crystal objects. I am sending the report thought Lotus Notes and it works fine.

I will still try to see what's the real cause of problem in my export using Crystal objects later... Thanks.

-M
 
If you are using MAPI, you need to have Outlook running so that the message can be sent.

If you are running Outlook XP, or have installed the security Pack, Outlook regards any third party product sending an email message as a potential virus, and will ask you to confirm you need to send the message. Editor and Publisher of Crystal Clear
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top