在Outlook外接程序中使用表单 [英] Using form in an outlook Add-in

查看:252
本文介绍了在Outlook外接程序中使用表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是VBA开发人员的经验,现在我正在尝试使用Visual Studio工具使用Visual Studio 2017开发Outlook的外接程序办公室。所以我是使用VS和VSTO的newbi。我创建了一个表单,我希望在Outlook中显示有关所选电子邮件的信息
。我创建了一个带按钮的ribon来加载并显示我的用户表单。到目前为止它工作正常,但我很困惑我如何检索有关所选电子邮件项目的信息。我将使用
代码类似于userform的初始化子中的下面显示的代码。

I'm an experience VBA developper, and now I'm trying to developpe an Add-in for Outlook using Visual Studio 2017 with Visual Studio Tools for Office. So I'm a newbi using VS ans VSTO. I have created a form on which I want to display information regarding the selected email in Outlook. I have created a ribon with a button to load and show my userform. So far it works fine, but I'm puzzled on how do I retrieve the information about the selected email item. I would have use a code similar to the one show below in the initialization sub of the userform.

Dim MsgIndex as integer
Dim MsgCount as integer
Dim MyEmail As Outlook.MailItem

	MsgCount = ActiveExplorer.Selection.Count
	If MsgCount <= 0 Then
		MsgIndex = 0
	Else
		MsgIndex = 1
	End If
	
    	if MsgIndex>=1 then
		Set MyEmail = ActiveExplorer.Selection(msgIndex)
		txtbox1.text= "Item " & MsgIndex & " of " MsgCount
		Txtbox2.text=MyEmail.Subject
	end if

但显然我无法访问"ActiveExplorer"来自userform代码。我尝试了一些变体,比如Outlook.application.ActiveExplorer或ThisAddIn ......所以如果有人知道如何处理程序,我会很高兴。

But apparently I can't access the "ActiveExplorer" from the userform code. I tried some variation like Outlook.application.ActiveExplorer or ThisAddIn... So if anyone have a clue on how to proced, I'll be greatfull.

你知道我能找到吗?例如,使用VSTO在用户表单上显示来自电子邮件的信息?

Do you know were I can find exemple in which information from an email is displayed on a userform using VSTO?

我也在寻找Visual Studio 2017和VSTO(Excel,Word,Outlook)的好参考书...)。

I'm also looking for a good reference book on Visual Studio 2017 and VSTO (Excel, Word, Outlook...).

谢谢

推荐答案

我会使用taskpane而不是windows窗体。它看起来更专业。我会给GitHub一个搜索。我确信Outlook VSTO上有一些例子。微软也有自己的
OfficeDev 帐户。这是我的
Office解决方案的项目文件夹。我没有Outlook的示例,但有几个在Excel中使用任务窗格的示例。 
I would use the taskpane rather than a windows form. It looks a bit more professional. I'd give GitHub a search. I'm sure there are a few examples on there for Outlook VSTO. Microsoft has their own OfficeDev account there as well. Here is my project folder for Office solutions. I don't have an example of Outlook, but there are several examples of using taskpanes in Excel. 


这篇关于在Outlook外接程序中使用表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆