Sending an email with a PDF: The parameter 'address' cannot be an empty string.

edited December 2010 in FastReport .NET
Hi,

I've a "The parameter 'address' cannot be an empty string." error and i couldn't find what i'm doing wrong.
wrote:
************** Texto de la excepci??n **************
System.ArgumentException: The parameter 'address' cannot be an empty string.
Nombre del par??metro: address
en System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding)
en FastReport.Export.Email.EmailExport.SendEmail(Report report)
en ExportToPDF.Form1.btnSilentExport_Click(Object sender, EventArgs e) en C:\Documents and Settings\toni\Mis documentos\Visual Studio 2010\Projects\Demos\VB.Net\ExportToPDF\Form1.vb:l?­nea 77
en System.Windows.Forms.Control.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnClick(EventArgs e)
en System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
en System.Windows.Forms.Control.WndProc(Message& m)
en System.Windows.Forms.ButtonBase.WndProc(Message& m)
en System.Windows.Forms.Button.WndProc(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I modified a sample project that I found in the distributable demo installer. The project is called ExportToPDF and is at Demos\VB.Net\ExportToPDF

I try to export the report in a PDF and then send it by email using MAPI. This means waking up a mailer, in my case Outlook 2007 with the text of the message already built and the report attached to email.

I'm using Visual Studio 2010 with VB and FastReports.NET Demo 1.5.31 i'm evaluating it.

I hope someone can help me!

    Private Sub btnSilentExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSilentExport.Click
        ' create report instance
        Dim report As New Report
        ' load the existing report
        report.Load("..\..\report.frx")
        ' register the dataset
        report.RegisterData(Me.FDataSet)
        ' run the report
        report.Prepare()
        ' create export instance
        Dim export As New PDFExport
        report.Export(export, "result.pdf")

        Config.EmailSettings.UseMAPI = True

        Dim ElEMailExport As FastReport.Export.Email.EmailExport = New FastReport.Export.Email.EmailExport

        ' EMail Properties        
        ElEMailExport.Address = "recipient@abc.co.uk"
        ElEMailExport.Subject = "Test"
        ElEMailExport.MessageBody = "Body of EMail"

        ' Send Mail        
        ElEMailExport.Export = export
        ElEMailExport.SendEmail(report)

        ' free resources used by report
        report.Dispose()
    End Sub

Comments

  • edited 10:56PM
    From: [2] (AlexTZ) Alexander Tzyganenko [helpdesk staff]

    >======================== MESSAGE ====================================

    Hello,

    You have not set the account properties such as the sender's address.

    // This example demonstrates the bare minimum required to send an email.
    EmailExport export = new EmailExport();
    export.Account.Address = "my@address.net";
    export.Account.Host = "myhost";
    export.Address = "recipient@address.net";
    export.Subject = "Re: analysis report"; // the report1 report must be prepared at this moment

    export.SendEmail(report1);

    >===================== END OF MESSAGE ================================

    Ok, it works !

    Now, i have a different problem that not affects the FastReport component. My ISP restricts the connections direct to his smtp server.

    Thanks for your help !

    Toni
  • edited 10:56PM
    visual visual programming example pdf is a book used for learning What Visual Basic is not, When You Program in VB, and The Visual Basic Interface.
    http://computersciencepdf.com/visual-basic...g-examples-pdf/
  • edited 10:56PM
    Remember to play it everyday to laugh more basketball games
  • edited 10:56PM
    Aw, this was a really nice post. In idea I would like to put in writing like this additionally ? taking time and actual effort to make a very good article? but what can I say? yapboz oyunları

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.