Outlook 表单上的此 VB 代码在 C# 中的等效项是什么?

发布于 2024-10-09 21:03:16 字数 598 浏览 0 评论 0原文

基本上,如何链接 Outlook 表单和 C# 后端?在 VB 中,您可以在表单上编写内容

Sub ButtonName_Click()
    Dim Recipients

    With Item.GetInspector.ModifiedFormPages("Message")
        Set Recipients = .Controls("To")
    End With
End Sub

,每当单击表单上名为“ButtonName”的按钮时,该表单就会触发,并将变量Recipients设置为To文本框。

现在我有一个自定义表单,还有一个 VS C# Outlook 插件,它们是两个独立的东西。我有一个可以捕获 MailItem 对象的事件处理程序,但我不知道如何处理自定义表单按钮单击,甚至不知道如何访问表单上的元素。

编辑 - 只是为了澄清一下,自定义表单是在 Outlook 中创建的,然后将其 .ofs 导入到 VS 中。 Outlook 和 VS 都是 2010。 此后我在 VS 中重新设计了表单。

Basically, how do I link an Outlook form and a C# back end? In VB you can write on the form

Sub ButtonName_Click()
    Dim Recipients

    With Item.GetInspector.ModifiedFormPages("Message")
        Set Recipients = .Controls("To")
    End With
End Sub

which will fire whenever the button named "ButtonName" on the form is clicked and will set the variable Recipients to a string of whatever is in the To text box.

Now I have a custom form, and I have a VS C# Outlook Add-in, and they're two separate things. I've got an event handler that can catch MailItem objects, but I don't know how to handle custom form button clicks or even how to access elements on the form.

EDIT - Just to clarify, the custom form was created in Outlook and then its .ofs was imported into VS. Both Outlook and VS are 2010. I have since redesigned the form in VS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

披肩女神 2024-10-16 21:03:16
  1. 双击表单上的按钮Name。这将为默认事件生成一个处理程序,在本例中恰好是“单击”。它将生成一个名为 buttonName_Click 的方法。
  2. string 类型的类中声明 recipientsprivate stringrecipients
  3. buttonName_Click 中根据需要分配给收件人

为了确切地知道要在处理程序中编写哪些代码,我需要知道这是什么类型的加载项。 C# 代码很可能类似于:

recipients = this.Item.GetInspector().ModifiedFormPages["Message"].Controls["To"];
  1. Double-click on the button Name on the form. This will generate a handler for the default event which happens to be "click" in this case. It will generate a method named buttonName_Click.
  2. Declare recipients in your class of type string: private string recipients.
  3. In buttonName_Click assign to recipients as appropriate.

In order to know exactly what code to write in the handler, I'll need to know what type of add-in this is. Most likely, the C# code will look something like:

recipients = this.Item.GetInspector().ModifiedFormPages["Message"].Controls["To"];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文