我想从一个列表项(在ItemCreated事件中)读取另一个新ListItem的附件。如何使用客户端对象模型执行此操作?我发现的只是服务器端代码......
另一个问题:删除列表项时是否还删除了附件,或者它们是否仍存在于服务器上?
答案 0 :(得分:0)
我明白了!以下代码对我有用:
IRibbonControl controlThatFiredEvent = e.Control;
object context = controlThatFiredEvent.Context;
if (context == null) return;
if (context is Outlook.Explorer)
{
Outlook.Explorer explorer = context as Outlook.Explorer;
Outlook.Selection selection = null;
try
{
selection = explorer.Selection;
}
catch (Exception ex)
{
}
if (selection != null)
{
if (selection.Count > 0)
{
object item = selection[1];
if (item is Outlook.ContactItem)
{
Outlook.ContactItem contact1 = item as Outlook.ContactItem;
// process contact
MessageBox.Show("ContactCallMenu_OnCreate - contact1: " + contact1.Subject);
}
Marshal.ReleaseComObject(item); item = null;
}
Marshal.ReleaseComObject(selection); selection = null;
}
}
else if (context is Outlook.Inspector)
{
Outlook.Inspector inspector = context as Outlook.Inspector;
object item = inspector.CurrentItem;
if (item is Outlook.ContactItem)
{
Outlook.ContactItem contact2 = item as Outlook.ContactItem;
// process contact
MessageBox.Show("ContactCallMenu_OnCreate - contact2: " + contact2.Subject);
}
Marshal.ReleaseComObject(item); item = null;
}
它将一个列表项(fromItem)的附件复制到新项目!