As subject
Hi Neal,
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,
Hi Kashif,
How do I upload image?
Hi Neal,
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,
Hi Kashif,
Thanks greatly for your help. I have got the permission to provide the sample excel.
Hi Neal,
Thank you! Kashif.
Hi Neal,