Emailing crystal reports (VS2005 + CR10)

Hi,

I have been trying without success for a couple of months now to email a Crystal Report in PDF format using the built in functionality, but all I ever get is a file named "untitled.txt" as an attachment. This is actually a PDF file with a txt extension, and if you change the extension, it loads up just fine.

I've been through all the KBs on the Business Objects site, had a support conversation (until the ticket got closed on me).

Anyone else had the same problem Any good solutions (Currently I have resorted to saving the file locally and manually creating a MAPI message and attaching it - pretty ugly stuff really.

Thanks in advance.

Richard


Answer this question

Emailing crystal reports (VS2005 + CR10)

  • Leon Mayne

    Have anyone found a solution to this issue Is it possible to rename the attachment

    Thanks,

    Frisco



  • Anatolik

    Hi, did you get this going on your side I need to do the same thing in my application.

    Please let me know.

    Thanks,

    JB..

  • Toby Leduc

    So far I have only been able to get this to work through an SMTP server like MS Exchange Server, but one work-around is to use the System.Net.Mail.MailMessage object. First create a CR report and export it in PDF format to a temporary file on disk, then send the file (named "reportFileName.pdf" in the following code snippet) in a MailMessage instance as an attachment:

    Code Block

    // Use client SMTP Server to send the notification e-mail messages

    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(CurrentUser.emailAddress, emailAddresses);

    message.Subject = "aiRows[0].ActionID + " Action Plan";

    message.Body = "See attached Action Plan " + qar.FormNumber;

    message.Attachments.Add(new System.Net.Mail.Attachment(reportFileName, System.Net.Mime.MediaTypeNames.Application.Pdf));

    try {

    smtpClient.Send(message);

    MessageBox.Show("e-mail notification sent to: " + emailAddresses, "Confirming notification");

    cmQMBActionActionItems_PositionChanged(this, EventArgs.Empty);

    }

    catch {

    string msg =

    "A problem was encountered connecting with the outgoing (SMTP) mail server;\n\r" +

    "unable to connect to " + smtpClient.Host + ".\n\r" +

    "Please ensure the correct server name is listed in the Configuration file";

    MessageBox.Show(this, msg, "Mail Server Connection Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);

    }

    finally {

    // Reset display of the Actions tab page to normal

    EnableActionPlanEMailControls(false);

    }

    As I said this works, but only with an instance of SmtpClient created with a valid SMTP server name (or corresponding IP address). Does anybody know how to use a local mail client, like MS Outlook, as an SMTP server for the SmtpClient class

    Mitchell


  • Chandu Sujay

    We have the same problem, but have a partial work-around (which I will post in the next reply). In case somebody can finally offer insight on how to fix the basic problem what follows is a description of how we would like to handle email reports through CR10 in VS2005:

    We are using CR for .NET with VS 2005 developing an application that needs to export PDF versions of reports as email attachments. While it works the problem we have is that the attachment is always named "untitled.txt". The attachment actually is a PDF - renaming the extension to "pdf" allows Adobe Reader to open and display the report just fine. Here is the code used to export the report:

    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts =
    CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormat Options();
    CrystalDecisions.Shared.MicrosoftMailDestinationOptions mailOpts =
    CrystalDecisions.Shared.ExportOptions.CreateMicrosoftMailDes tinationOptions();
    CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();

    pdfOpts.UsePageRange = false;
    exportOpts.ExportFormatOptions = pdfOpts;

    mailOpts.MailMessage = "See attached Action Plan for " + qar.FormNumber;
    mailOpts.MailSubject = aiRows[0].ActionID + " Action Plan";
    mailOpts.MailToList = emailAddresses;
    exportOpts.ExportDestinationOptions = mailOpts;

    exportOpts.ExportDestinationType =
    CrystalDecisions.Shared.ExportDestinationType.MicrosoftMail;
    exportOpts.ExportFormatType =
    CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;

    report.Export(exportOpts);

    What can we do to supply a meaningful name for the attached file, and ensure it bears the correct "pdf" extension

    Thanks,

    Mitchell


  • NeederOfVBHelp

    noooooooooooooooooooo. I tought I would find an answer over here.

    I got the exact same problem here. I dont know how to change the name of the attachment that is send by email from Crystal Report Destination Options things

    God. Well, lets continue googling...........

    Good luck



  • Emailing crystal reports (VS2005 + CR10)