加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – 如何序列化邮件?

发布时间:2020-12-15 20:08:50 所属栏目:asp.Net 来源:网络整理
导读:当使用los foratter串连化一个mial消息时,我得到以下内容. 错误:Sys.WebForms.PageRequestManagerServerErrorException:错误序列化System.Net.Mail.MailMessage类型为“System.Net.Mail.MailMessage”的值. 有没有一个简单的方法来序列化这个对象,或者我要
当使用los foratter串连化一个mial消息时,我得到以下内容.

错误:Sys.WebForms.PageRequestManagerServerErrorException:错误序列化System.Net.Mail.MailMessage类型为“System.Net.Mail.MailMessage”的值.

有没有一个简单的方法来序列化这个对象,或者我要分别搜索每个ofhte属性?

解决方法

可惜的是,System.Net.Mail.MailMessage类没有被标记为可序列化.所以,是的,你需要自己去做.以下博客文章中介绍的技术可以让您了解如何继续: How to Serialize a MailMessage …基本上,您将需要单独拉出每个属性.引用:

To serialize the properties of a MailMessage object you can create a
new class and create a property of MailMessage type for it that embeds
your MailMessage in the class. In this new class you can implement
IXmlSerializable interface to manually serialize its MailMessage. Here
I create this class and call it SerializableMailMessage […]

[code implementation of WriteXml() and ReadXml() methods follow; see source link]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读