public void SendReport(CrashReportDetails crashReport) { // Create xml file containing reportItems string prettyXml = ""; using (System.IO.StringWriter stringWriter = new System.IO.StringWriter()) { System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces(); ns.Add("", ""); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(crashReport.GetType(), crashReport.GetItemTypes()); x.Serialize(stringWriter, crashReport, ns); prettyXml = stringWriter.ToString(); } using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(new System.IO.MemoryStream())) { streamWriter.WriteLine(prettyXml); streamWriter.Flush(); streamWriter.BaseStream.Position = 0; ZipStore.AddStream(System.IO.Compression.ZipStorer.Compression.Deflate, "crashrpt.xml", streamWriter.BaseStream, DateTime.Now, ""); } ZipStore.Close(); // Upload File HttpUploadFile(HttpUrl, ZipStream.ToArray(), FileParamName, FileName, "application/x-zip-compressed", HttpParams); }
public void SendReport(CrashReportDetails crashReport) { // Create xml file containing reportItems string prettyXml = ""; using (System.IO.StringWriter stringWriter = new System.IO.StringWriter()) { System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces(); ns.Add("", ""); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(crashReport.GetType(), crashReport.GetItemTypes()); x.Serialize(stringWriter, crashReport, ns); prettyXml = stringWriter.ToString(); } using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(new System.IO.MemoryStream())) { streamWriter.WriteLine(prettyXml); streamWriter.Flush(); streamWriter.BaseStream.Position = 0; ZipStore.AddStream(System.IO.Compression.ZipStorer.Compression.Deflate, "crashrpt.xml", streamWriter.BaseStream, DateTime.Now, ""); } ZipStore.Close(); ZipStream.Position = 0; // Upload File HttpUploadFile(HttpUrl, ZipStream, FileParamName, FileName, "application/x-zip-compressed", HttpParams); }
public void SendReport(CrashReportDetails crashReport) { // Convert ReportItems to EmailBody string emailBody = ""; using (System.IO.StringWriter stringWriter = new System.IO.StringWriter()) { System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces(); ns.Add("", ""); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(crashReport.GetType(), crashReport.GetItemTypes()); x.Serialize(stringWriter, crashReport, ns); emailBody = stringWriter.ToString(); } using (MailMessage msg = new MailMessage()) { msg.From = new MailAddress(EmailFromAddress); foreach (string s in EmailToAddress.Split(";".ToCharArray())) { msg.To.Add(s); } if (String.IsNullOrEmpty(EmailSubject)) { msg.Subject = Application.ProductName + " - Error Report"; } else { msg.Subject = EmailSubject; } msg.Body = emailBody; SmtpClient smtp = null; if (String.IsNullOrEmpty(EmailHost)) { smtp = new SmtpClient(); } else { if (EmailPort == 0) { smtp = new SmtpClient(EmailHost); } else { smtp = new SmtpClient(EmailHost, EmailPort); } } if (String.IsNullOrEmpty(EmailUsername) && String.IsNullOrEmpty(EmailPassword)) { smtp.UseDefaultCredentials = true; } else { smtp.Credentials = new System.Net.NetworkCredential(EmailUsername, EmailPassword); } smtp.EnableSsl = EmailSSL; smtp.Send(msg); } }
public void SendReport(CrashReportDetails crashReport) { // Convert ReportItems to EmailBody string emailBody = ""; using (System.IO.StringWriter stringWriter = new System.IO.StringWriter()) { System.Xml.Serialization.XmlSerializerNamespaces ns = new System.Xml.Serialization.XmlSerializerNamespaces(); ns.Add("", ""); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(crashReport.GetType(), crashReport.GetItemTypes()); x.Serialize(stringWriter, crashReport, ns); emailBody = stringWriter.ToString(); } using (MailMessage msg = new MailMessage()) { msg.From = new MailAddress(EmailFromAddress); foreach (string s in EmailToAddress.Split(";".ToCharArray())) { msg.To.Add(s); } if (String.IsNullOrEmpty(EmailSubject)) msg.Subject = Application.ProductName + " - Error Report"; else msg.Subject = EmailSubject; msg.Body = emailBody; SmtpClient smtp = null; if (String.IsNullOrEmpty(EmailHost)) { smtp = new SmtpClient(); } else { if (EmailPort == 0) smtp = new SmtpClient(EmailHost); else smtp = new SmtpClient(EmailHost, EmailPort); } if (String.IsNullOrEmpty(EmailUsername) && String.IsNullOrEmpty(EmailPassword)) smtp.UseDefaultCredentials = true; else smtp.Credentials = new System.Net.NetworkCredential(EmailUsername, EmailPassword); smtp.EnableSsl = EmailSSL; smtp.Send(msg); } }