Excel content in mail is not formatted correctly in Outlook2010- but correctly in Outlook2003

As subject

Hi Neal,


Thank you for writing to us.

Could you please tell if you are using Aspose.Email to generate such a message file? Please provide us such a sample message along with your sample code so that we can investigate this issue further. I would request you to please attach some comparative screenshots as well for both the versions for our analysis.

Hi Kashif,

Thanks for replying to me in such a short time. Yes, I used Aspose.Email to generate the mail. The problem is that some border lines will be missing when Excel content be read and put in mail body. I can’t show you the mail sample because it contains sensetive data. But I can show you the code snippet. Hope it can help you. Thanks in advance.

using System.IO;
using System.Net.Mail;

string Subject = appContext._EmailSubject;
Subject = Subject.Replace("", traderName);
Subject = Subject.Replace("yyyymmdd", date);

Aspose.Cells.License licCells = new Aspose.Cells.License();
licCells.SetLicense(@"Aspose.Total.lic");
Aspose.Email.License licEmail = new Aspose.Email.License();
licEmail.SetLicense(@"Aspose.Total.lic");

// Load the desired workbook from disk and save to stream as MHTML

//Workbook workbook = new Workbook(@"C:\test\Some_file.xls");
Workbook workbook = null;
workbook = new Workbook(FileName);


for (int i = 1; i < workbook.Worksheets.Count; i++)
{
    workbook.Worksheets[i].IsVisible = false;
}
Worksheet ws = workbook.Worksheets[0];

ws.Cells.InsertRow(0);
ws.Cells.Merge(0, 0, 1, 8);
Cell firstCell = workbook.Worksheets[0].Cells[0, 0];

firstCell.HtmlString = appContext._EmailHeader;
Style style = firstCell.GetStyle();
style.IsTextWrapped = true;
firstCell.SetStyle(style);
ws.Cells.SetRowHeight(0, 100);


MemoryStream mhtmlStream = new MemoryStream();
workbook.Save(mhtmlStream, SaveFormat.Html);
mhtmlStream.Position = 0;

StreamReader f = new StreamReader(mhtmlStream);

string htmlBody = f.ReadToEnd();
//Define a new Message object and set its HtmlBody

MailMessage message = new MailMessage();
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
message.HtmlBody = htmlBody;
message.IsBodyHtml = true;

if (HighImportance)
{
    message.Priority = MailPriority.High;
}


// Load the MHTML in MailMessage
if (ToEmail != null && "" != ToEmail)
{
    message.To = ToEmail;
}

message.Subject = Subject;
message.From = appContext._EmailFrom;
if (ccEmail != null && "" != ccEmail)
{
    message.CC = ccEmail;
}
if (bccEmail != null && "" != bccEmail)
{
    message.Bcc = bccEmail;
}
message.ReplyToList = replyToEmail;

message.Attachments.Add(new Attachment(FileName));

SmtpClient client = new SmtpClient();
client.Host = appContext._EmailServer;
//Specify your mail user name
client.Username = appContext._EmailUser;
//Specify your mail password
client.Password = appContext._EmailPassword;
//Specify your Port #
client.Port = appContext._Port;
client.Send(message); string Subject = appContext._EmailSubject;
Subject = Subject.Replace("", traderName);
Subject = Subject.Replace("yyyymmdd", date);

Aspose.Cells.License licCells = new Aspose.Cells.License();
licCells.SetLicense(@"Aspose.Total.lic");
Aspose.Email.License licEmail = new Aspose.Email.License();
licEmail.SetLicense(@"Aspose.Total.lic");

// Load the desired workbook from disk and save to stream as MHTML
//Workbook workbook = new Workbook(@"C:\test\Some_file.xls");
Workbook workbook = null;
workbook = new Workbook(FileName);

for (int i = 1; i < workbook.Worksheets.Count; i++)
{
    workbook.Worksheets[i].IsVisible = false;
}

Worksheet ws = workbook.Worksheets[0];

ws.Cells.InsertRow(0);
ws.Cells.Merge(0, 0, 1, 8);
Cell firstCell = workbook.Worksheets[0].Cells[0, 0];

firstCell.HtmlString = appContext._EmailHeader;
Style style = firstCell.GetStyle();
style.IsTextWrapped = true;
firstCell.SetStyle(style);
ws.Cells.SetRowHeight(0, 100);


MemoryStream mhtmlStream = new MemoryStream();
workbook.Save(mhtmlStream, SaveFormat.Html);
mhtmlStream.Position = 0;

StreamReader f = new StreamReader(mhtmlStream);

string htmlBody = f.ReadToEnd();
//Define a new Message object and set its HtmlBody

MailMessage message = new MailMessage();
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
message.HtmlBody = htmlBody;
message.IsBodyHtml = true;

if (HighImportance)
{
    message.Priority = MailPriority.High;
}

// Load the MHTML in MailMessage
if (ToEmail != null && "" != ToEmail)
{
    message.To = ToEmail;
}

message.Subject = Subject;
message.From = appContext._EmailFrom;
if (ccEmail != null && "" != ccEmail)
{
    message.CC = ccEmail;
}
if (bccEmail != null && "" != bccEmail)
{
    message.Bcc = bccEmail;
}
message.ReplyToList = replyToEmail;

message.Attachments.Add(new Attachment(FileName));

SmtpClient client = new SmtpClient();
client.Host = appContext._EmailServer;
//Specify your mail user name
client.Username = appContext._EmailUser;
//Specify your mail password
client.Password = appContext._EmailPassword;
//Specify your Port #
client.Port = appContext._Port;
client.Send(message);

Hi Neal,


Thank you for the feedback.

However, we are unable to reproduce this issue in absence of a sample source file and providing such a file will help us investigate the issue further for reporting to our development team. Moreover, I regret I won’t be able to test this issue due to unavailability of Outlook 2003 and comparative screenshots will help us identify any such issue for further investigation. Looking forward to assist you further.

Hi Kashif,

How do I upload image?

Hi Neal,


Please provide us the screenshot and sample Excel file by uploading it in your reply to this message. Below the text writing area, there is an option to upload files. Please use that to uplaod the screenshot as well as problematic Excel file.

Hi Kashifv,

Thanks for your tips. Now I can upload images. The first image is for Outlook2003 which is the good one, the second is for Outlook2010. As you can see, compared with Outlook2003, Outlook2010 misses some border lines. Sorry I cannot provide Excel smple due to security issue. Can you tell what the problem is based on the images?

Hi Neal,


I have tried to reproduce the issue here by adding a sample excel file as email body. This mail is sent and viewed in Outlook 2010 but no error is found in the formatting of excel file borders.

Could you please test the scenario by deleting all the data from the excel file and just keeping the border formatting? If problem is re-producible, send us the empty excel file. It will help us to analyze the problem and provide you assistance as soon as possible.

Hi Kashif,

Thanks greatly for your help. I have got the permission to provide the sample excel.

Hi Neal,


Thanks for providing the sample.

I was able to observe the issue and have logged it as: NETWORKNET-34070 in our issue tracking system for further investigation by development team. We’ll let you know once the fix version is available for this issue and appreciate your patience until then.

Thank you! Kashif.

Hi Neal,


We have investigated this issue further and foudn that it is the problem of html display in Outlook. If you save BodyHtml of received message in a separate html file, the table is displayed correctly. If you do the same in Outlook, the table there is represented as OLE object and, thus, is displayed corrently.