hi,
I generated one word document using aspose.word and I tried to send the word doc. through mail. The mail attachment document is not opening.
I am using both Windows 2000 server and 2003. In 2000 server. The code is working, but it fails in 2003 server
Explore the sample code below. I am waiting for ur reply
// Put user code to initialize the page here
Words.Document doc = new Words.Document();
// This truly makes the document empty. No sections (not possible in Microsoft Word).
doc.RemoveAllChildren();
// Create a new section node.
// Note that the section has not yet been added to the document,
// but we have to specify the parent document.
Words.Section section = new Words.Section(doc);
// Append the section to the document.
doc.AppendChild(section);
// Lets set some properties for the section.
section.PageSetup.SectionStart = Words.SectionStart.NewPage;
section.PageSetup.PaperSize = Words.PaperSize.Letter;
// The section that we created is empty, lets populate it. The section needs at least the Body node.
Words.Body body = new Words.Body(doc);
section.AppendChild(body);
// The body needs to have at least one paragraph.
// Note that the paragraph has not yet been added to the document,
// but we have to specify the parent document.
// The parent document is needed so the paragraph can correctly work
// with styles and other document-wide information.
Words.Paragraph para = new Words.Paragraph(doc);
body.AppendChild(para);
// We can set some formatting for the paragraph
para.ParagraphFormat.StyleName = "Heading 1";
para.ParagraphFormat.Alignment = Words.ParagraphAlignment.Center;
// So far we have one empty pararagraph in the document.
// The document is valid and can be saved, but lets add some text before saving.
// Create a new run of text and add it to our paragraph.
Words.Run run = new Words.Run(doc);
run.Text = "Sample NewsClips document";
//run.Font.Color = System.Drawing.Color.Red;
para.AppendChild(run);
// Add 2nd Para
Words.Paragraph para2 = new Words.Paragraph(doc);
body.AppendChild(para2);
para2.ParagraphFormat.StyleName = "Normal";
para2.ParagraphFormat.Alignment = Words.ParagraphAlignment.Left;
Words.Run run2 = new Words.Run(doc);
run2.Text = "This sample document will display the NewsClips";
para2.AppendChild(run2);
//Add a table of contents
//Words.Field toc = new Words.Field();
// As a matter of interest, you can retrieve text of the whole document and
// see that \x000c is automatically appended. \x000c is the end of section character.
//Assert.AreEqual("Hello World!\x000c", doc.GetText());
// Save the document.
doc.Save(@"D:\AsposeTest.doc");
doc = null;
MailMessage msg = new MailMessage();
MailAttachment objattach = new MailAttachment(@"D:\AsposeTest.doc");
msg.From = "username@domain.com";
msg.To = "username@domain.com";
msg.Attachments.Add(objattach);
msg.Subject = "Test";
SmtpMail.SmtpServer = "mail.mailserver.com";
SmtpMail.Send(msg);
Aravind M