如何使用Outlook自动化创建邮件时使To-address为只读?

时间:2021-09-14 18:51:47

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:

使用Office自动化在Outlook中创建和显示邮件时,是否可以将“收件人”文本框设置为只读?我们使用以下代码来创建消息:

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

1 个解决方案

#1


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.

我知道没有简单的方法,但一种方法是使用P / Invoke和本机API将文本框的状态设置为只读。它涉及获取文本框的句柄,这是棘手的部分。如果您使用Spy ++,您可以深入了解窗口的层次结构以及如何处理它。

#1


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.

我知道没有简单的方法,但一种方法是使用P / Invoke和本机API将文本框的状态设置为只读。它涉及获取文本框的句柄,这是棘手的部分。如果您使用Spy ++,您可以深入了解窗口的层次结构以及如何处理它。