We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Is there a way to restore RichText formated email with embedded imges intact?

Hi,

I want to know is there a way to restore Email formatted using RichText formatting? and if yes how?

I have attached a sample email. I found some methods on following links but dont know their usage:



  1. EmbedLinkedImagesIntoRtf Method

  2. AddEmbeddedImageToRtfBody Method

Can you help with this?

Thanks.

Hi Jason,

Thank you for writing to Aspose support team.

ININPSO:

I want to know is there a way to restore Email formatted using RichText formatting? and if yes how?

Could you please elaborate your requirements to help us assist you further? With respect to the mentioned properties, I was unable to find any working example of these methods and your feedback will enable us to further investigate this requirement.

Hey Kashif,

I will be glad to give you more information but frankly speaking there is not any. I am getting an object for an email which is formatted using “RichText” formatting. The object consists of all the required information about email. I want to reconstruct MSG file using object and save it to hard disk. If possible, I am looking for following steps with code from you.

  1. Use attached email as sample email
  2. Create Aspose MailMessage object from the sample email.
  3. Save MSG file using creted MailMessage object.
  4. Attach newly generated MSG file to thread.

Hi Jason,


To create an Aspose MailMessage object from the sample email you have provided, you can use the following sample code. Please let us know if this doesn’t meet your requirements. We’ll look into it for assisting you further.

Sample Code:

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:blue;mso-no-proof:yes”>string<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> dir = “Email_548008\”;<o:p></o:p>

MailMessage msg = MailMessage.Load(dir + "Test RichText formatting.msg");

Console.WriteLine(msg.BodyType.ToString());

MailMessage newMsg = newMailMessage();

foreach (LinkedResource lr in msg.LinkedResources)

newMsg.LinkedResources.Add(lr);

foreach (Attachment at in msg.Attachments)

newMsg.Attachments.Add(at);

newMsg.HtmlBody = msg.HtmlBody;

newMsg.Save(dir + "NewMsg.msg", MailMessageSaveType.OutlookMessageFormatUnicode);


Hi Jason,


To create an Aspose MailMessage object from the sample email you have provided, you can use the following sample code. Please let us know if this doesn’t meet your requirements. We’ll look into it for assisting you further.

Sample Code:

<span style=“font-size:
10.0pt;font-family:“Courier New”;color:blue;mso-no-proof:yes”>string<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> dir = “Email_548008\”;<o:p></o:p>

MailMessage msg = MailMessage.Load(dir + "Test RichText formatting.msg");

Console.WriteLine(msg.BodyType.ToString());

MailMessage newMsg = newMailMessage();

foreach (LinkedResource lr in msg.LinkedResources)

newMsg.LinkedResources.Add(lr);

foreach (Attachment at in msg.Attachments)

newMsg.Attachments.Add(at);

newMsg.HtmlBody = msg.HtmlBody;

newMsg.Save(dir + "NewMsg.msg", MailMessageSaveType.OutlookMessageFormatUnicode);


The object I am receiving for Email, embedded images are saved in collection named attachments and all images have name exactly same i .e. “Picture (Device Independent Bitmap)”. Just to be clear i am not getting a MSG file but I am getting C#.NET object. I have attached MSG file which i have generated from the .net object. I am not sure how can you recreate the situation I am in because the library is proprietary.

I have also attached original MSG file. This email was translated to .net Object explained above and i want to restore this message but I cant because of the reasons mentioned above.

Can you help me with this?

Hi Jason

I have analyzed the requirements and have perceived that you are not getting any file but data stream from some source and want to convert that into MailMessage. To demonstrate this behavior, I have performed the following tasks.

MailMessage msg = MailMessage.Load("OriginalMessage.msg");
MemoryStream stream = new MemoryStream();
msg.Save(stream, MailMessageSaveType.OutlookMessageFormatUnicode);

//Here the message is available in stream of byte

//Convert the byte array to MailMessage
MailMessage newMsg = MailMessage.Load(stream);
newMsg.Save("SavedMessage.msg", MailMessageSaveType.OutlookMessageFormatUnicode);

Could you please review this code and let us know if it fulfills your requirements? If it is not the case, please send us the steps to convert the source message into C# .NET object as it will help us to re-produce the scenario here and provide solution as soon as possible.