com - Automating Outlook and Word to create email message -
I am trying to create a single word message that will be used as a body for Outlook message. I am looking at the sample code from Microsoft but this code falls when trying to create a new word document on the wordApp.Documents.Add line:
Word Apps Word app = new word Applications (); Object template = system Reflection. Measuring. Value; Object newTemplate = System.Reflection.Missing.Value; Object Document Type = Word VdNewDocumentType.wdNewEmailMessage; Object view = wrong; Word Document Word Doc = Word App. Documents.ed (Ref Template, Ref Newsletter, Referee Document Type, Ref. Visible); Outlook.MailItemClass mItem = (Outlook.MailItemClass) doc.MailEnvelope.Item; I get a COM exception of "Command unsuccessful" I am using Office 2007 and I have tried: - Standard Office 12 word And refer to Outlook libraries
- Installing Office XP PIA and referencing Office 12 libraries
- Installing Office XP PIAs and referencing Office 2000 libraries.
- Uninstall Office XP PIAs and reference Office 2000 / Office 2007 libraries. I get the same error every time if I change the document type from wdNewEmailMessage to wdNewBlankDocument, it works but I do not want a normal word document, I want an email document. I throw error using a differnt type document - Outlook.MailItemClass
Ideally I would like to work on Word 2000 on Word 2007; -)
Comments
Post a Comment