Reputation: 155
I have an Excel sheet. The data is pretty straight forward in a few columns and rows. There is some formatting done on the cells (example.. colors, bold font, etc). I am using c# to send email. I wish to basically copy the contents of the Excel sheet and paste it in the body of the email with the formatting maintained.
Is this even possible? Am I talking BS?
Upvotes: 0
Views: 3050
Reputation: 2954
That's not an easy one. I mean you would have to check the style of every character in every cell! Wouldn't it be easier to just send the excel sheet? If you provide more information about WHY you are doing it like this we might be able to suggest some alternatives which won't be so time consuming!
Edit:
The easiest is to use the Workbook.SendMail()
method.
The Code:
Excel.Workbook myWorkbook = xlApp.Workbooks["Book1.xls"];`
string recipients = "[email protected]";
string subject = "No need to open the attachment, you lazy ****";
bool returnReceipt = false;
myWorkbook.SendMail(recipients, subject, returnReceipt);
Note that the recipients parameter is actually typed as System.Object so that the argument passed in can be a string[] if you have multiple recipients.
Upvotes: 1