Sending an email with a PDF: The parameter 'address' cannot be an empty string.
Hi,
I've a "The parameter 'address' cannot be an empty string." error and i couldn't find what i'm doing wrong.
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!
I've a "The parameter 'address' cannot be an empty string." error and i couldn't find what i'm doing wrong.
************** 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
>======================== 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
http://computersciencepdf.com/visual-basic...g-examples-pdf/