CustomTaskPanes 和从 Outlook 外部调用 NewMailMessage
我有一个功能区按钮出现在 Outlook 撰写电子邮件表单的 tabNewMailMessage 上,此按钮可切换粘贴在表单侧面的 CustomTaskPane 的可见性。
在正常实践中,一切都很完美。但是,当通过“附加到电子邮件”或“保存并保存”调用撰写电子邮件表单时,从 MS Word 或 Adobe Reader 等其他应用程序发送',该按钮会出现,但不再执行任何操作。
我从 MSDN 了解到,在外部调用的情况下 NewInspector 事件显然不会触发。
我一直无法找到解决此问题的任何方法,这里有人知道吗? :(
编辑:此外,我有一个 Global 类(不是 Visual Studio 创建的隐藏 GlobalS 类),其中包含我在整个程序中使用的一些变量。Addin 也根本不会加载其中包含的任何内容。很难说实际上加载了什么,如果有人有更多信息,请
再次编辑:测试将字符串放入 ThisAddIn 并通过切换按钮中的消息框打印它,但不起作用如果有人感到困惑,则功能区按钮将不会加载。单击事件无法执行,因此外部调用的 Compose 表单似乎会跳过 ThisAddIn 中的所有代码以及不是功能区本身的任何类,
我真的需要帮助来解决这个问题:(
再次编辑:这就是什么。到目前为止,我发现 ThisAddIn 启动事件不会触发,无法读取外部类中的任何属性,但像 ThisAddIn.SayHelloWorld() 这样的外部方法可以
再次编辑
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//MessageBox.Show(,"TEST");
try
{
inspectors = Globals.ThisAddIn.Application.Inspectors;
inspectors.NewInspector += new InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
foreach (Inspector insp in inspectors)
{
//insp.
Inspectors_NewInspector(insp);
}
}
catch (System.Exception ex)
{
List<string> lalala = new List<string>();
lalala.Add(ex.GetType().ToString());
lalala.Add(ex.Message);
lalala.Add(ex.StackTrace);
File.WriteAllLines(@"C:\outdebug",lalala.ToArray());
}
}
:
void Inspectors_NewInspector(Inspector Inspect)
{
try
{
if (Inspect.CurrentItem is MailItem)
{
Global.mail = Inspect.CurrentItem;
Global.inspectorWrappersValue.Add(Inspect, new InspectorWrapper(Inspect, Global.mail));
//inspectorw
}
}
catch (System.Exception ex)
{
List<string> lalala = new List<string>();
lalala.Add(ex.GetType().ToString());
lalala.Add(ex.Message);
lalala.Add(ex.StackTrace);
lalala.Add(Global.SiteConnectionManager.ToString());
File.WriteAllText(@"C:\Users\cat\Desktop\outdebug.txt", string.Join("\n", lalala), Encoding.UTF8);
}
}
I have a ribbon button that appears on tabNewMailMessage in Outlook's compose email form, this button toggles the visibility of a CustomTaskPane stuck to the side of the form.
In normal practice, everything works perfectly. But when the Compose Email form is invoked via 'Attach to email' or 'Save & Send' from other applications like MS Word or Adobe Reader, the button appears but no longer does anything.
I learned from MSDN that the NewInspector event apparently does not fire in the case of external invocation.
I have not been able to find any workarounds for this case, does anybody here know? :(
EDIT : Additionally, I have a Global class (not the hidden GlobalS class that Visual Studio creates) that contains some variables I use across the entire program. The Addin will not load anything contained in there at all either. It's hard to tell what actually does get loaded, if anyone has more information, holler back please!
EDIT Again : Tested putting string in ThisAddIn and printing it through a messageBox in toggleButton, didn't work. If anyone is confused, the ribbon button will not load if the click-event is impossible to execute, so it seems that externally invoked Compose forms skip all code in ThisAddIn and any class that isn't the ribbon itself.
I really need help figuring this out! :(
EDIT Yet Again : Here is what I've garnered so far, ThisAddIn startup events will not fire, no properties in external classes may be read from, but external methods like say ThisAddIn.SayHelloWorld() do work.
EDIT again! :
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//MessageBox.Show(,"TEST");
try
{
inspectors = Globals.ThisAddIn.Application.Inspectors;
inspectors.NewInspector += new InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
foreach (Inspector insp in inspectors)
{
//insp.
Inspectors_NewInspector(insp);
}
}
catch (System.Exception ex)
{
List<string> lalala = new List<string>();
lalala.Add(ex.GetType().ToString());
lalala.Add(ex.Message);
lalala.Add(ex.StackTrace);
File.WriteAllLines(@"C:\outdebug",lalala.ToArray());
}
}
Again! :
void Inspectors_NewInspector(Inspector Inspect)
{
try
{
if (Inspect.CurrentItem is MailItem)
{
Global.mail = Inspect.CurrentItem;
Global.inspectorWrappersValue.Add(Inspect, new InspectorWrapper(Inspect, Global.mail));
//inspectorw
}
}
catch (System.Exception ex)
{
List<string> lalala = new List<string>();
lalala.Add(ex.GetType().ToString());
lalala.Add(ex.Message);
lalala.Add(ex.StackTrace);
lalala.Add(Global.SiteConnectionManager.ToString());
File.WriteAllText(@"C:\Users\cat\Desktop\outdebug.txt", string.Join("\n", lalala), Encoding.UTF8);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好在 ThisAddIn.Startup 中的所有代码周围使用 try/catch 处理程序,因为 Outlook 会积极地处理所有异常,因此如果出现问题,您将永远不会知道。
但是,我认为真正导致您出现问题的是 http://social.msdn.microsoft.com/Forums/en/vsto/thread/60c75274-e15a-4696-afa6-79de8fbd707d。解决方案是创建一个计时器并在触发时检查是否存在现有检查员。我下面的内容应该会有很大帮助,但这不是一个完整的解决方案,因为它不能处理 NewInspector 触发并且计时器也指示检查员的情况。因此,您必须添加一些逻辑以确保不会为检查器添加 2 个任务窗格。
It is a good idea to use try/catch handlers around all your code in ThisAddIn.Startup, because Outlook is aggressive about eating all exceptions, so if there is a problem you will never know it.
However, I think what is really causing you a problem is an Outlook issue discussed at http://social.msdn.microsoft.com/Forums/en/vsto/thread/60c75274-e15a-4696-afa6-79de8fbd707d. The solution is to create a timer and check if there are existing inspectors when it fires. What I have below should help out a lot, but it's not a complete solution because it doesn't handle the case where NewInspector fires and the timer also indicates an inspector. So you will have to add some logic to make sure you don't add 2 task panes for an inspector.