简体   繁体   English

从用户定义的字段填充 Outlook 表单主题

[英]Populate Outlook form Subject from user-defined fields

I designed the form below:我设计了以下表格:
在此处输入图片说明

I would like the Subject to be automatically populated with the value of "[Machine] - [TAT]" as soon as those values are filled.我希望在填充这些值后立即自动填充“[Machine] - [TAT]”的值。 I don't know how to access the values of these fields, the syntax for the value change listeners, nor where I should be putting this code.我不知道如何访问这些字段的值、值更改侦听器的语法,也不知道我应该把这段代码放在哪里。

When I click "Visual Basic", all I see is this:当我单击“Visual Basic”时,我看到的是:

在此处输入图片说明

It seems that this is only programmatic access to the Application, not the form.似乎这只是对应用程序的编程访问,而不是表单。

How do I programmatically access the form that I designed?如何以编程方式访问我设计的表单?

Legacy form customizations require using VBScript for the "code behind", primarily for interactions with your custom UI.传统表单自定义需要将 VBScript 用于“代码隐藏”,主要用于与自定义 UI 的交互。 However, VBA macros are used independent of custom forms to work with Outlook items and data.但是,VBA 宏独立于自定义表单使用,以处理 Outlook 项目和数据。 If the business logic for your custom form requires working with the active MailItem, then VBScript is what you need to use.如果您的自定义表单的业务逻辑需要使用活动的 MailItem,那么您需要使用 VBScript。

For your scenario, you need to trap changes to the values of your custom controls.对于您的方案,您需要捕获对自定义控件值的更改。 The best practice is to create custom fields in the Outlook item and map those fields to the controls.最佳做法是在 Outlook 项目中创建自定义字段并将这些字段映射到控件。 If you don't, you will only be able to write validation formulas in the designer for those controls, and you cannot trap value changes (odd, I know).如果不这样做,您将只能在设计器中为这些控件编写验证公式,并且无法捕获值更改(奇怪,我知道)。 Luckily custom fields fire the Item_CustomPropertyChange event, which is exactly what you need.幸运的是,自定义字段会触发 Item_CustomPropertyChange 事件,这正是您所需要的。

For more info, see:有关更多信息,请参阅:

Manipulating Controls Programmatically MailItem.CustomPropertyChange Event 以编程方式操作控件MailItem.CustomPropertyChange 事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM