c# - 检查初次发送邀请后已更新的约会项目
问题描述
我有一个与项目发送事件相关联的 Outlook 插件。当用户单击发送时,我会得到一个收件人列表并检查外部地址。我需要能够区分在原始项目发送后已更新的 Outlook 约会项目。
是否有 DASL 属性、赎回属性或标准约会项目属性来确定这一点?
对于邮件项,我检查 ConversationIndex 字符串的长度,如果长度为 44,我知道这是一条新消息。如果大于 44,我知道这是回复或转发。
//for example
Outlook.MailItem mailItem = Item as Outlook.MailItem;
string convID = mailItem.ConversationIndex;
if ((convID.Length = 44)) //new messages are always 44
{ //do something }
我希望对新的约会项目进行类似的检查,但约会项目的对话指数没有增加。
这个问题- 链接 -类似但不一样,因为 FInvited DASL 属性在项目发送后始终为真。
解决方案
我可以通过订阅 Outlook.InspectorsEvents_NewInspectorEventHandler 事件来检查新的会议/约会项目,当此事件被触发时,您可以检查 fInvited DASL 属性。由于此事件在 ItemSend 事件之前触发,因此我始终知道当前项目的 fInvited 值。
这是一个示例,我希望将来对其他人有所帮助:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
olInspectors = this.Application.Inspectors;
olInspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(Compose_New_Message_Inspector);
}
public bool AppointmentSent { get; set; }
static void Main(string[] args)
{
void Compose_New_Message_Inspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
try
{
var Item = Inspector.CurrentItem;
if (Item is Outlook.MailItem)
{
//not concerned with mail items
}
else if (Item is Outlook.AppointmentItem)
{
// added to check if an appontment is new or if it's beeing updated or has alredy been sent
// fInvited=false if meeting is newly composed and true if it has already been sent
Outlook.AppointmentItem apptItem = Item as Outlook.AppointmentItem;
bool fInvited;
try
{
fInvited = apptItem.PropertyAccessor.
GetProperty("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/8229000B");
Debug.WriteLine("fInvited =" + fInvited);
AppointmentSent = fInvited;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
try
{
if (apptItem != null)
{
Marshal.ReleaseComObject(apptItem);
}
}
catch (Exception ex)
{
}
}
// To hangle right-click action (Forward Meeting or Foward occurrences)
// fInvited=false if meeting is newly composed and true if it has already been sent
else if (Item is Outlook.MeetingItem)
{
Outlook.MeetingItem meetingItem = Item as Outlook.MeetingItem;
bool fInvited;
try
{
fInvited = meetingItem.PropertyAccessor.
GetProperty("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/8229000B");
Debug.WriteLine("fInvited =" + fInvited);
AppointmentSent = fInvited;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
try
{
if (meetingItem != null)
{
Marshal.ReleaseComObject(meetingItem);
}
}
catch (Exception ex)
{
}
}
try
{
if (Item != null)
{
Marshal.ReleaseComObject(Item);
}
}
catch (Exception ex)
{
}
}
catch (Exception ex)
{
}
}
}
推荐阅读
- css - 将 Tailwind CSS 与 vue-sfc-rollup 一起使用
- jquery - 如何使用 ajax post 方法传递值。值被传递到视图中。但是模板没有通过上下文的值
- java - 是否有任何情况下 SecurityContext 在请求后不会从 ThreadLocal 中清除?
- php - ffmpeg 4.3 多部分修剪问题
- javascript - 显示没有悬停chartjs的点数据
- django - 创建仅列出与用户相关的对象的序列化程序
- c# - 在 ASP.net 应用程序中集成 SAML2 应用程序
- google-apps-script - 从 Google Script 导出的 PDF 包含多个空白页面
- python - PyInstaller 后 tkinter GUI 黑屏
- proxy - 如何使用 Puppeteer docker 加载自己的自定义代理列表