mail crtstalrepoprt

Last post 07-08-2009 5:42 AM by oidldb. 17 replies.

Sort Posts:

  • mail crtstalrepoprt

    06-17-2009, 7:37 AM

    HI All,

              I am using VS05 + CrystalReport + c# . I have creste crystalreport. I want when click on "EMAIL" button then this crystalreport should mail to particlar mail id.

             In short i want to give emailing facility to crystalreport. The procedure in c# is appriciated.

    Thanks in advance.

  • Re: mail crtstalrepoprt

    06-17-2009, 8:02 AM
    • All-Star
      27,395 point All-Star
    • qwe123kids
    • Member since 03-27-2008, 9:49 AM
    • Mumbai
    • Posts 4,628

     Hi,

    Try using CreateMHTMLBody
    whih send Whole Page As mail..

    Go in Page drictives and make Aspcompanent true then use

    <%
    Set myMail=CreateObject("CDO.Message")
    myMail.Subject="Sending email with CDO"
    myMail.From="mymail@mydomain.com"
    myMail.To="someone@somedomain.com"
    myMail.CreateMHTMLBody "http://server.com/asp/Mypage.aspx"
    myMail.Send
    set myMail=nothing
    %>

    for More information

    http://www.eggheadcafe.com/articles/20040527.asp

    Thanks
    Avinash Tiwari

    Remember to click “Mark as Answer” on the post, if it helps you.

    MY Blog

    Hacking Inside .net exe
  • Re: mail crtstalrepoprt

    06-17-2009, 8:36 AM

    Hi, i have two pages . On first page there is dropdown when i select value from this dropdown and click submit button , page redirect to second page where crystalreportviewer is placed. On this page according to selection particular report get called.

    I cant get how to use your solution in this condition?

    Thank You.

  • Re: mail crtstalrepoprt

    07-06-2009, 6:10 AM

    Santoshkhadkebeed thanks for your post. I have answered for your question in this thread. please ref this

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: mail crtstalrepoprt

    07-07-2009, 8:40 AM

    HI jeyaseelan,

    I have gone through the link. But really cant get how is it helpful to solve my problem ie. "How to mail Crystal Report".

    Thank You. 

  • Re: mail crtstalrepoprt

    07-07-2009, 8:59 AM
    • Contributor
      2,730 point Contributor
    • CoolBond
    • Member since 10-25-2007, 1:34 PM
    • Country
    • Posts 535

     Hi,

         In export of crystal report you have option to send the report as mail attachment(PDF is the best suitable format) . You can use this method. Please refer the below threads(laziness in creating sample :D) In case if you need help still, i will create a sample applcaition.

    http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_21382253.html

    Hope this will help you....

    " If people criticize you, hurt you, or shout at you,Don't be bothered. Just remember, In every game, audience make the noise, not the players "
  • Re: mail crtstalrepoprt

    07-07-2009, 9:04 AM

    santoshkhadkebeed thanks for your post.

    Tell me which part you are struggled

    1.Have you created and binded records to crystal report?

    2.Have you written the code to export the report into PDF/Excel?

    3.Have you written the code to send a mail with the attachment?

    In above points where you struggled so that i can help you.

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: mail crtstalrepoprt

    07-07-2009, 9:10 AM

    HI jeyaseelan,

    The link you provide is http://forums.asp.net/t/1442510.aspx . It talks @ Custom page size. Where it talk @ mail crystalreport.

    Thank You.

  • Re: mail crtstalrepoprt

    07-07-2009, 9:48 AM

    santoshkhadkebeed thanks for your post.

    I gave the wrong url sorry for that. Let me explain clearly if you want to mail your report then you have to do these.

    1. Bind all the records into Report.

    2. Export all the records into PDF file at one fixed area(it may be D drive or anything) Ref this

    3. WRite the code to send a mail with attachment like this and this

     

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: mail crtstalrepoprt

    07-07-2009, 11:26 PM
    • Member
      404 point Member
    • you_rock
    • Member since 07-17-2008, 2:11 AM
    • Posts 154

    this is truly a helpful reference. Two thumbs up :)


  • Re: mail crtstalrepoprt

    07-08-2009, 2:11 AM

     HI jeyaseelan,

                 I have below situation

    1) I have first page which is having twp datetime pickers ie.FromDate and ToDate. When i click submit button at that time second page is open like this,

    Response.Write("<script>window.open('MK_View_PotentialClientList.aspx?fromdate=" + fromdate + "&todate=" + todate + "','User','toolbar=no,width=1000,height=600,left=5,top=5,scrollbars=1')</script>");

    2) This second page contains below code,

     protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                fromdate = Convert.ToDateTime(Request.QueryString["fromdate"].ToString().Trim());
                todate = Convert.ToDateTime(Request.QueryString["todate"].ToString().Trim()); 
                
                paramField.Name = "@FromDate";
                paramDiscreteValue.Value = fromdate;
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
    
                paramField = new ParameterField();
                paramField.Name = "@ToDate";
                paramDiscreteValue = new ParameterDiscreteValue();
                paramDiscreteValue.Value = todate;
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
    
                // Assign all parameters to store procedure for crystalreportviewer
                CrystalReportViewer1.ParameterFieldInfo = paramFields;
    
                //************************set the report path***********************
                reportDocument.Load(Server.MapPath("MK_rpt_PotentialClientList.rpt"));
    
                //**********************dynamic databse login*********************************************
                ConnectionInfo connection = new ConnectionInfo();
    
                connection.DatabaseName = Application["DBName"].ToString();
                connection.ServerName = Application["DBServer"].ToString();
                connection.UserID = Application["DBUserId"].ToString();
                connection.Password = Application["DBPassword"].ToString();
                //******************** First we assign the connection to all tables in the main report
                foreach (CrystalDecisions.CrystalReports.Engine.Table table in reportDocument.Database.Tables)
                {
                    //*********************************Cache the logon info block
                    TableLogOnInfo logOnInfo = table.LogOnInfo;
    
                    //*************************************Set the connection
                    logOnInfo.ConnectionInfo = connection;
    
                    //******************************Apply the connection to the table!
                    table.ApplyLogOnInfo(logOnInfo);
                }
                          //******************************Load the report by setting the report source
                CrystalReportViewer1.ReportSource = reportDocument;
                CrystalReportViewer1.Visible = false;
    
                string fileName = Server.MapPath("MK_rpt_PotentialClientList.rpt");
                doc.Load(fileName); 
                ExportOptions ExpOptions = default(ExportOptions);
                DiskFileDestinationOptions DiskFileDestOpts = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions FormatTypeOpts = new PdfRtfWordFormatOptions();
                DiskFileDestOpts.DiskFileName = "E:\\Test.pdf";
                ExpOptions = doc.ExportOptions;
                {
                    ExpOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    ExpOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                    ExpOptions.DestinationOptions = DiskFileDestOpts;
                    ExpOptions.FormatOptions = FormatTypeOpts;
                }
                doc.Export(); 
              
            }
            catch (Exception ex)
            {
                Trace.Warn(ex.Message.ToString());
                Trace.Warn(ex.Source.ToString());
                Trace.Warn(ex.TargetSite.ToString());
            }
        }

    Here i am using Stored Procedure to pass parameters,

    Below is the error.....

    "Missing parameter values."

    What changes i have to do here?

    Thank You.

     

     

  • Re: mail crtstalrepoprt

    07-08-2009, 2:50 AM

    Here i am using Stored Procedure to pass parameters,

    Below is the error.....

    "Missing parameter values."

    What changes i have to do here?

    Thank You.

    In the sense you are passing some parameters to Stored Procedure am i right?

    Then this problem is due to

     You are not pass the value to SP parameters because your procedure didnt accept null value.

    So check the number of paramters you are passing from front-end(it should have data) and it should equal to number of parameters in SP.

     

     

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: mail crtstalrepoprt

    07-08-2009, 3:11 AM

    HI jeyaseelan,

     Yes i am using stored procedure. If there is any mismatch in parameter then the report is not visible for me. If i run this report without the code for export then there is not problem for report generation.

    can you please go throgh the code.There you might get something which i miss.

    Thank You. 

  • Re: mail crtstalrepoprt

    07-08-2009, 3:22 AM

    santoshkhadkebeed thanks for your post.

    In your post there is no code for Database operation it has only Report based code, so you have to post how you pass the value to SP parameter and also post your SP so that i can help you.

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: mail crtstalrepoprt

    07-08-2009, 4:07 AM

    HI jeyaseelan,

    Below is my code,

     	fromdate = Convert.ToDateTime(Request.QueryString["fromdate"].ToString().Trim());
                todate = Convert.ToDateTime(Request.QueryString["todate"].ToString().Trim()); 
                
                paramField.Name = "@FromDate";
                paramDiscreteValue.Value = fromdate;
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
    
                paramField = new ParameterField();
                paramField.Name = "@ToDate";
                paramDiscreteValue = new ParameterDiscreteValue();
                paramDiscreteValue.Value = todate;
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
    
                // Assign all parameters to store procedure for crystalreportviewer
                CrystalReportViewer1.ParameterFieldInfo = paramFields;
    
                //************************set the report path***********************
                reportDocument.Load(Server.MapPath("MK_rpt_PotentialClientList.rpt"));
     
    MK_rpt_PotentialClientList.rpt is my crystalreport    
    @FromDate,@ToDate are my parameters to S.P.
    in MK_rpt_PotentialClientList.rpt i have get the storedprocedure which require to view parameter on report.
     
    Do you have any alternative method to pass parameter to S.P. for crystalreport
    
    Thank You.
    


     

Page 1 of 2 (18 items) 1 2 Next >