/// <summary> /// Returns serializable alternate view object /// </summary> /// <param name="alternateView"></param> /// <returns></returns> public static SerializableAlternateView GetSerializableAlternateView(AlternateView alternateView) { if (alternateView == null) { return(null); } var serializedAlternateView = new SerializableAlternateView { serializedContentId = alternateView.ContentId, baseUri = alternateView.BaseUri }; if (alternateView.ContentStream != null) { var bytes = new byte[alternateView.ContentStream.Length]; alternateView.ContentStream.Read(bytes, 0, bytes.Length); serializedAlternateView.serializedContentStream = new MemoryStream(bytes); } serializedAlternateView.serializedContentType = SerializableContentType.GetSerializableContentType(alternateView.ContentType); foreach (var lr in alternateView.LinkedResources) { serializedAlternateView.serializedLinkedResources.Add(SerializableLinkedResource.GetSerializableLinkedResource(lr)); } serializedAlternateView.transferEncoding = alternateView.TransferEncoding; return(serializedAlternateView); }
/// <summary> /// Serializable Mail Message Contstructor /// </summary> /// <param name="mailMessage">Original Mail Message to be serialized</param> public SerializableMailMessage(MailMessage mailMessage) { MailID = Guid.NewGuid().ToString(); this.IsBodyHtml = mailMessage.IsBodyHtml; this.Body = mailMessage.Body; this.Subject = mailMessage.Subject; this.SerializedFrom = SerializableMailAddress.GetSerializableMailAddress(mailMessage.From); this.serializedTo = new List <SerializableMailAddress>(); foreach (var ma in mailMessage.To) { this.serializedTo.Add(SerializableMailAddress.GetSerializableMailAddress(ma)); } this.serializedBcc = new List <SerializableMailAddress>(); foreach (var ma in mailMessage.Bcc) { this.serializedBcc.Add(SerializableMailAddress.GetSerializableMailAddress(ma)); } this.serializedCC = new List <SerializableMailAddress>(); foreach (var ma in mailMessage.CC) { this.serializedCC.Add(SerializableMailAddress.GetSerializableMailAddress(ma)); } this.serializedReplyTo = new List <SerializableMailAddress>(); foreach (var ma in mailMessage.ReplyToList) { this.serializedReplyTo.Add(SerializableMailAddress.GetSerializableMailAddress(ma)); } this.serializedAttachments = new List <SerializableAttachment>(); foreach (var att in mailMessage.Attachments) { this.serializedAttachments.Add(SerializableAttachment.GetSerializeableAttachment(att)); } this.bodyEncoding = mailMessage.BodyEncoding; this.serializedDeliveryNotificationOptions = mailMessage.DeliveryNotificationOptions; this.serializedHeaders = SerializableCollection.GetSerializableCollection(mailMessage.Headers); this.mailPriority = mailMessage.Priority; this.SerializedSender = SerializableMailAddress.GetSerializableMailAddress(mailMessage.Sender); this.subjectEncoding = mailMessage.SubjectEncoding; foreach (var av in mailMessage.AlternateViews) { this.serializedAlternateViews.Add(SerializableAlternateView.GetSerializableAlternateView(av)); } }