This is a migrated thread and some comments may be shown as answers.

Send a report by email

6 Answers 781 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
armando
Top achievements
Rank 1
armando asked on 07 Nov 2007, 07:13 PM
Can you help me I don't Know if has an option to send a report by e-mail direct from the ReportViewer?

Thanks

6 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 09 Nov 2007, 10:54 AM
Hi Armando,

The Report Viewers (Win and Web) do not support sending of reports via e-mail out-of-the-box. To mail a report you have to first render the report into a convenient format and then attach it to a mail message. Here is a possible way of how to achieve this by using the SmtpClient object:

        void MailReport(Telerik.Reporting.Report report, string from, string to, string subject, string body)
        {
            string mimeType;
            string extension;
            Encoding encoding;

            byte[] reportBytes =
                ReportProcessor.Render("PDF", report, null, out mimeType, out extension, out encoding);
          
            MemoryStream ms = new MemoryStream(reportBytes);
            ms.Position = 0;
           
            Attachment attachment = new Attachment(ms, report.Name + "." + extension);
            MailMessage msg = new MailMessage(from, to, subject, body);
            msg.Attachments.Add(attachment);
            SmtpClient client = new SmtpClient(smptHost);
            client.Send(msg);                       
        }


Some more information about sending e-mails from .net you can find here.

Regards,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
manu
Top achievements
Rank 1
answered on 29 Apr 2008, 11:20 AM
Hi,
I am using the above code and it is working fine if i use Session Mode as "Inproc"  but i got error if i use Session mode as "SQLServer". the error is :

System.Web.HttpException: Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. ---> System.Runtime.Serialization.SerializationException: Type 'Telerik.Reporting.Drawing.Shapes.LineSegment' in Assembly 'Telerik.Reporting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' is not marked as serializable.     at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)     at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)     at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()     at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)     at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)     at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[

My website is hosted on shared system and it cause session time out frequently if i use "InPro" Session mode. so I must to use "SQLServer" session mode. Please provide some solution ASAP...

thankx
0
Chavdar
Telerik team
answered on 29 Apr 2008, 01:13 PM
Hi manu,

The fix for this problem will be available for the service pack release due in a couple of weeks. We are sorry for the inconvenience.

Regards,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jon Kaneshiro
Top achievements
Rank 1
answered on 02 Feb 2009, 09:44 PM
I am having the same problem when setting sessionmode to sqlserver.
I tried both Q2 2009 SP2 and 2008_1209, but it's still giving me the same problem.
I originally had Q1 2008 SP1, but because I ran into this problem, I upgraded it to the above versions.
I made sure that the versions in the config file match those of newer version, but it's still not working.
Do you know what I may have to do to fix this?

I would appreciate your help.


Thanks,
0
Steve
Telerik team
answered on 03 Feb 2009, 12:11 PM
Hi Jon,

It is not clear from your post, whether you are having this problem because of the "send email" code snippet or are you having general problems with Telerik Reports and OutProc session. If the latter, please open separate threads for the issue, as one that has been opened for another subject and has been answered might not be reviewed.
Currently when you use an OutProc session state mode (SQLServer, StateServer), the Web report viewer would only store the report’s type in the ASP.NET session. This unfortunately leads to some unpleasant limitations:

    * The report class should have a default constructor.
    * It is impossible to use a constructor with parameters to customize the report.
    * All modifications to the report instance made outside the default constructor of the report are lost.

As a temporary workaround, we believe that you might get this working by keeping your "parameter" in Session and access it in the report's default constructor through the HttpContext.Current.Session. We are already working on out of the box solution for Q1.

Please excuse us for the inconvenience.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jon Kaneshiro
Top achievements
Rank 1
answered on 03 Feb 2009, 10:02 PM
Steve,

I will create another posting relating to the issue.
Also, thank you for your response to my question.
It seems that I may have to wait until you release the patch.


Thanks,
Tags
General Discussions
Asked by
armando
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
manu
Top achievements
Rank 1
Jon Kaneshiro
Top achievements
Rank 1
Steve
Telerik team
Share this question
or