我是Outlook加载项编程的新手,不确定这是否可行:
我想显示一个弹出窗体(或选择),并在他们单击"发送"时询问用户输入.基本上,每当他们发送电子邮件(新邮件或回复邮件)时,都会要求他们在下拉框中选择一个值(最好从SQL数据库中列出项目).根据他们的选择,文本消息将附加到邮件的主题.
我做了我的研究,看起来我应该使用表单区域,但我不确定当用户单击发送时如何显示弹出/额外表单.此外,看起来Form Areas可用于扩展/替换当前的VIEW邮件表单,但我可以将其用于CREATE NEW表单吗?
谢谢大家的时间.
小智 5
您可以在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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2610 次 |
| 最近记录: |