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

Free Support Forum - aspose.com

HTML Body is alignment and spaces are getting loosed

Hello Aspose Team,


I am using Aspose.Email version 6.0.0.0

When i am storing html string in aspose as HTML Body the alignment are not setting properly

Here is my sample code :

class Program
{
static void Main(string[] args)
{
MapiMessage m_mapiMsg = null;
Aspose.Email.Mail.MailMessage test_mail = new Aspose.Email.Mail.MailMessage();
test_mail.Subject = “Hello Test mail”;
test_mail.HtmlBody = File.ReadAllText(“C:\html_body.html”);
m_mapiMsg = MapiMessage.FromMailMessage(test_mail);
m_mapiMsg.Save(“C:\Saved_using_Aspose_Mail_message.msg”);
}
}

I have also attached the source html file(html_body.html) which has html string and also store the save msg file(Saved_using_Aspose_Mail_message.msg) using the Aspose.Email SDK.

Please find both file in the Sample_files.zip attachment.

Please let us know about this solution as earliest as possible.

Thanks in advance.

Regards,
Shital Diwate


Hi Shital,


Thank you for contacting Aspose support team.

This issue is observed here and logged under Id : EMAILNET-35121 for further investigation by the product team. I shall write here as soon as some feedback is received in this regard.

Hello Team,


Is there any update on my query, we are on deadline.

Can you please provide me solution ASAP.

Thank You.

Regards,
Shital

Hi Shital,


I have checked the status of the ticket and it is planned to be resolved in our upcoming release in the first week of March, 2016. You will be automatically notified once the issue is resolved and new updated library is available online for download.

Hello Team,


As we have purchased the SDK and March is a bit late.

We are already behind our schedule, we need this solution at earlier possible.

And our client are also facing these issue.

Is there any possibility to provide us some work around ?

And also after the saving the .msg file using your SDK & when we open the msg file in outlook it is editable, can you please also look to this.

Can you please take this case at priority and provide us the solution ASAP.

Thank You.

Regards,
Shital


Hi Shital,

The issue is yet to be investigated and fixed in the upcoming version of Aspose.Email for .NET 6.2.0. We are afraid that we could not find any work around method to get the desired output. If the issue is of critical nature, you can consider subscribing to our Priority support service where the issues are dealt on priority basis. However, please note that if the issue involves complexity, it may take time even if the issue is considered on priority basis.

You can use the MapiMessageFlags.MSGFLAG_UNSENT to mark the message as sent/uneditable. Please try it at your end and let us know your feedback.

Sample Code:

MapiMessage mapi = new MapiMessage();
mapi.Subject = “Hello Test mail”;
mapi.SetBodyContent(File.ReadAllText(“html_body.html”), Aspose.Email.Outlook.BodyContentType.Html);

mapi.SetMessageFlags(mapi.Flags & ~MapiMessageFlags.MSGFLAG_UNSENT);
mapi.Save(“Saved_using_Aspose_Mail_message_6_1.msg”);

Hi Shital,

As a work around, could you please try the following sample code and let us know your feedback?

Sample Code:

MapiMessage mapi = new MapiMessage();
mapi.Subject = “Hello Test mail”;
mapi.SetBodyContent(File.ReadAllText(“html_body.html”), Aspose.Email.Outlook.BodyContentType.Html);
mapi.RemoveProperty(MapiPropertyTag.PR_RTF_COMPRESSED);
mapi.Save(“Saved_using_Aspose_Mail_message_6_1.msg”);

Hello,


The Html body problem is solved, but to store inline attachment,
earlier we were using Aspose.Email.Mail.MailMessage and Aspose.Email.Mail.Attachment to store inline and non-line attachments like this : (*attach is my created object)

here is the code to store attachments in mail message (f_create_MSG is the object of MailMessage)

m_aspose_attach = new Aspose.Email.Mail.Attachment(Other_File);
m_aspose_attach.Name = Other_File;
m_aspose_attach.ContentId = attach.ContentID;
m_aspose_attach.ContentDisposition.FileName = Other_File;
m_aspose_attach.ContentDisposition.Inline = true;
m_aspose_attach.ContentDisposition.CreationDate = attach.CreationTime;
m_aspose_attach.ContentDisposition.Size = attach.FileSize;
f_create_MSG.Attachments.Add(m_aspose_attach);

so if i go with the Mail message object and set the html body in Mapi message object and save the msg like this

m_mapiMsg = MapiMessage.FromMailMessage(msg_path);
m_mapiMsg.SetBodyContent(f_HtmlBody, Aspose.Email.Outlook.BodyContentType.Html);
m_mapiMsg.RemoveProperty(MapiPropertyTag.PR_RTF_COMPRESSED);

the html body becomes null.

So can you tell me how to store inline & non-inline attachments in MapiMessage object.
so that i can use only MapiMessage class instead of MailMessage with respect to attachement and html body problem.

Please let us know about it as earliest as possible.

Thank You.

Regards,
Shital



Hi Shital,


We are sorry but there is no other way to save it until the issue is fixed. The above method was suggested keeping in view your requirements of directly generating the MSG file and the issue will be further fixed in the upcoming version of Aspose.Email for .NET 6.3.0. You can further find about adding attachments to a MapiMessage by visiting our documentation section, working with message attachments.

Hello,


Is there any update on my previous post, please try to understand we need the solution ASAP.

We are already behind our schedule.

Please take this case on high priority or please escalate this case to higher management.

Thank You.

Regards,
Shital
Hello,

I know how to add the attachment but is there any other way to add inline attachment in MapiMessage ??

Thank You.

Regards,
Shital

Hi Shital,

Please use the following sample code to add inline image using Mapimessage.

Sample Code:

var imgName = “Desert.jpg”;<o:p></o:p>

string htmltext = @"this is a test
this is a test
this is a test



this is a test this is a test
this is a test this is a test
this is a test this is a test
"
;

MapiMessage mapi = new MapiMessage();

mapi.SetBodyContent(htmltext, BodyContentType.Html);

mapi.Attachments.Add("Desert.jpg", File.ReadAllBytes(imgName));

mapi.Save("MapiWithInlineImage.msg");

Hello Team,

I have tested the same thing as you told one in your earlier reply.

Its still not working.

Please refer sample code in the following :

class Program
{
static void Main(string[] args)
{

MailMessage a1 = new MailMessage();
a1.From = "hello@gmail.com";
a1.To = "hello@gmail.com";
MapiMessage p1 = new MapiMessage();
p1 = MapiMessage.FromMailMessage(a1);
p1.SetBodyContent(File.ReadAllText("C:\\test_html.html"), Aspose.Email.Outlook.BodyContentType.Html);
p1.RemoveProperty(MapiPropertyTag.PR_RTF_COMPRESSED);
p1.Attachments.Add("image001.jpg", File.ReadAllBytes("C:\\image001.jpg"));
p1.Subject = "Hello Test";
p1.SetMessageFlags(p1.Flags & ~MapiMessageFlags.MSGFLAG_UNSENT);
p1.Save("C:\\test_inline.msg");

}
}

Please also tell me, if i have done some thing wrong in the code.

I've also attached the exported msg and source html file, please find the content in the attachments.

Please as i told you we are already running behind our schedule, please provide us atleast working solution.

I have also checked with RTF body too, its having same problem.

Thank You.

Regards,
Shital
Hi Shital,

Please make the following corrections:

1. src="cid:image001.jpg" alt="Email Migration Clients"/>

2. p1 = MapiMessage.FromMailMessage(a1, MapiConversionOptions.UnicodeFormat);

or use the MapiMessage constructor:

p1 = new MapiMessage("hello@gmail.com", "hello@gmail.com", "", "");
Hello Team,

How can we change the scr="cid:attachment-file-name" in html body at run time.

We cannot manipulate the content on HTML body.

Its not possible !!!!!!!!!!!!!!

Thank You.

Regards,
Shital

Hi Shital,


I meant, you have to prepare in advance a proper html content (not at runtime).
Please correct the test_html.html

Hello Team,


Sorry i didn’t understood, could you please demonstrate example with sample code.

Thank You.

Regards,
Shital.

Hi Shital,


You may please give a try to the following sample code and let us know the feedback:

private static void Email_689821()<o:p></o:p>

{

GenerateMessage("image002.jpg");

}

private static void GenerateMessage(string newImageName)

{

MapiMessage p1 = p1 = new MapiMessage("hello@gmail.com", "hello@gmail.com", "", "");

string text = File.ReadAllText("test_html.html");

text = text.Replace("src=\"", "src=\"cid:");

text = text.Replace("image001.jpg", newImageName);

File.WriteAllText("test_html.html", text);

p1.SetBodyContent(File.ReadAllText("test_html.html"), Aspose.Email.Outlook.BodyContentType.Html);

p1.RemoveProperty(MapiPropertyTag.PR_RTF_COMPRESSED);

p1.Attachments.Add(newImageName, File.ReadAllBytes(path + newImageName));

p1.Subject = "Hello Test";

p1.SetMessageFlags(p1.Flags & ~MapiMessageFlags.MSGFLAG_UNSENT);

p1.Save("test_inline.msg");

}

If it does not fulfill your requirement, please explain in detail what do you mean by the following:

Shital diwate:
How can we change the scr="cid:attachment-file-name" in html body at run time.

We cannot manipulate the content on HTML body.

Its not possible !!!!!!!!!!!!!!

The issues you have found earlier (filed as EMAILNET-35121) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hello Team,


As per seeing my post, you might be knowing my problem.

In your last reply your team mates have told me that the problem of html body will be solved in new release in march.

So it there any update of it.

Please let me know about it.

Thanks in advance.

Regards,
Shital