views:

163

answers:

1

Is it possible to set the To textbox to be read-only when you create and display a mail message in outlook with Office automation? We use the following code to create the message:

   Outlook.Application objOutlook = new Outlook.Application();
   Outlook.MailItem mail = (Outlook.MailItem)objOutlook.CreateItem(OlItemType.olMailItem);
   // setting properties...
   mail.Display(modal);
+1  A: 

There's no easy way that I know of, but one way is to use P/Invoke and native APIs to set the state of the textbox to read-only. It involves getting a handle to the textbox, which is the tricky part. If you poke around with Spy++, you may get insight into the window's hierarchy and how to get it's handle.

lc