gpt4 book ai didi

VSTO - Outlook 2007 - 在发送消息之前显示表单?

转载 作者:行者123 更新时间:2023-12-04 19:23:35 26 4
gpt4 key购买 nike

我是 Outlook 插件编程的新手,不确定这是否可行:

我想显示一个弹出表单(或选择)并在用户单击“发送”时要求用户输入。基本上,每当他们发送电子邮件(新建或回复)时,他们都会被要求在下拉框中选择一个值(最好是从 SQL 数据库中列出项目)。
根据他们的选择,将在邮件主题后附加一条文本消息。

我做了我的研究,看起来我应该使用表单区域,但我不确定当用户单击发送时如何显示弹出窗口/额外表单。
此外,看起来表单区域可用于扩展/替换当前的 VIEW 邮件表单,但我可以将它用于创建新表单吗?

谢谢大家的时间。

最佳答案

您可以在 ThisAddIn Internal Startup 方法中添加 Item Send 事件处理程序,然后在 Item Send Event 中调用自定义窗体(Windows 窗体)。
在下面的示例中,在发送电子邮件项之前和单击发送按钮之后,我将自定义窗口窗体称为模式对话框。

private void InternalStartup()
{
this.Application.ItemSend += new ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}

void Application_ItemSend(object Item, ref bool Cancel)
{
if (Item is Microsoft.Office.Interop.Outlook.MailItem)
{
Microsoft.Office.Interop.Outlook.MailItem currentItem = Item as Microsoft.Office.Interop.Outlook.MailItem;
Cancel = true;
Forms frmProject = new ProjectForm();;

DialogResult dlgResult = frmProject.ShowDialog();

if (dlgResult == DialogResult.OK)
System.Windows.Forms.SendKeys.Send("%S"); //If dialog result is OK, save and send the email item
else
Cancel = false;

currentItem.Save();
currentItem = null;
}
}

关于VSTO - Outlook 2007 - 在发送消息之前显示表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1740287/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com