Outlook 表单上的此 VB 代码在 C# 中的等效项是什么?
基本上,如何链接 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Name
。这将为默认事件生成一个处理程序,在本例中恰好是“单击”。它将生成一个名为buttonName_Click
的方法。string
类型的类中声明recipients
:private stringrecipients
。buttonName_Click
中根据需要分配给收件人
。为了确切地知道要在处理程序中编写哪些代码,我需要知道这是什么类型的加载项。 C# 代码很可能类似于:
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 namedbuttonName_Click
.recipients
in your class of typestring
:private string recipients
.buttonName_Click
assign torecipients
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: