0

I have a html page which is attached to the email as word document.

string body = String.Empty;
body = new StreamReader("execlude.html").ReadToEnd(); 
byte[] data = Encoding.ASCII.GetBytes(body);
MemoryStream ms = new new MemoryStream(data);
var message = new System.Net.Mail.MailMessage(email.From, email.To);
message.Attachments.Add(new Attachment(ms, "excluded.doc", "application/msword"));

Here the attachment becomes word format, but the margin are too big. Let me know a solution to remove margins.

Thanks in advance.

S.Spieker
  • 7,005
  • 8
  • 44
  • 50
  • I think you will need to make it a proper word document. A beginning: http://www.c-sharpcorner.com/UploadFile/muralidharan.d/how-to-create-word-document-using-C-Sharp/ – mortb Apr 06 '16 at 07:33