【问题标题】:Prompt Outlook user to enter the value of a user defined property if not already assigned提示 Outlook 用户输入用户定义属性的值(如果尚未分配)
【发布时间】:2022-07-15 22:28:57
【问题描述】:

我正在尝试拦截任何新消息或回复消息,并提示发件人输入用户定义字段的值(如果尚未分配给该消息)。

基本流程应该是:
用户点击发送
检查字段值是否为空
如果为空,输入框收集值并应用
发送电子邮件

用户定义的字段已经到位,我可以创建一个表单模板来发送新电子邮件,允许发件人在发送前输入值。这旨在作为对新消息的验证,并在回复以前的消息时创造申请机会。

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    陷阱Application.ItemSend 事件。在事件处理程序中,使用MailItem.UserProperties 集合来检查用户属性是否已经存在。如果没有,请使用InputBox 函数显示提示。通过MailItem.UserProperties.Add 使用返回值添加用户属性。

    【讨论】:

      【解决方案2】:

      每当发送 Microsoft Outlook 项目时,应用程序类的 ItemSend 事件就会被触发,或者由用户通过 Inspector(在检查器关闭之前,但在用户单击 Send 按钮之后)或在程序中使用 Outlook 项目的 Send 方法(例如 MailItem)时。这是起点:

      Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)  
       Dim prompt As String  
       prompt = "Are you sure you want to send " & Item.Subject & "?"  
       If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then  
         Cancel = True  
       End If  
      End Sub
      

      但是您可以使用InputBox 函数代替消息框。它在对话框中显示提示,等待用户输入文本或单击按钮,并返回包含文本框内容的字符串。

      Dim Message, Title, Default, MyValue
      Message = "Enter a value between 1 and 3"    ' Set prompt.
      Title = "InputBox Demo"    ' Set title.
      Default = "1"    ' Set default.
      ' Display message, title, and default value.
      MyValue = InputBox(Message, Title, Default)
      

      最后,UserProperties.Add 方法在UserProperties 集合中创建了一个新的用户属性。

      Sub AddUserProperty(myItem as MailItem) 
       Dim myUserProperty As Outlook.UserProperty 
       
       Set myUserProperty = myItem.UserProperties.Add("SampleTextUserProperty", olText) 
       myUserProperty.Value = "test"
      
      End Sub
      

      【讨论】:

      • 我似乎无法让它工作。我什至尝试将 Microsoft 的 ItemSend 复制/粘贴到一个类模块中,只是为了看看这是否会给我一个消息框。什么都没发生。我错过了一些非常基本的东西吗?
      猜你喜欢
      • 1970-01-01
      • 2015-04-22
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      相关资源
      最近更新 更多