[英]Outlook 2010 VSTO - Non-Admin users receive “The operation failed.” when Task.Save is called
I have an Outlook add-in that is working successfully for about 100 users. 我有一个Outlook加载项,它可以成功为约100个用户使用。 It interacts with our application and creates/updates Tasks and Appointment items.
它与我们的应用程序交互,并创建/更新任务和约会项。 However, one client cannot get it to work for anyone who is not a network administrator.
但是,一个客户端不能使它对于不是网络管理员的任何人都起作用。 Through some logging, I can see that it works fine until it gets to the part where it should save the Task, and then it throws the infamous "The operation failed."
通过一些日志记录,我可以看到它运行良好,直到到达应保存Task的部分,然后抛出了臭名昭著的“操作失败”。 error.
错误。 I have tried in vain to get more error details by investigating inner exceptions and such, but "The operation failed."
我徒劳地尝试通过调查内部异常之类来获取更多错误详细信息,但是“操作失败”。 is all I can seem to get out of it.
我似乎可以摆脱的一切。
To make it simpler to debug, I eliminated our application from the picture and wrote them a test add-in that just creates 9 tasks (hard-coded to "Task 1", "Task 2", etc.) and it fails in the same place with the same error. 为了简化调试,我从图片中删除了我们的应用程序,并为他们编写了一个测试加载项,该加载项仅创建了9个任务(硬编码为“任务1”,“任务2”等),并且在同一个地方,同样的错误。 I have asked them to write a macro to see if a macro is able to create tasks for these users.
我已要求他们编写一个宏,以查看宏是否能够为这些用户创建任务。 I am awaiting their reply on that.
我正在等待他们的答复。
Anyway, I have been on MSDN for over a month trying to get help on the issue and nobody has been able to help. 无论如何,我已经在MSDN上工作了一个多月,试图获得有关该问题的帮助,但是没有人能够提供帮助。 I am hoping someone here could shed some light.
我希望这里的人能有所启发。 If you can provide any insight on what might be happening or suggestions to help me track down the problem, it would be greatly appreciated!
如果您可以提供有关可能发生的情况的任何见解或可以帮助我找出问题的建议,将不胜感激!
This is the function I am using to create the sample tasks in the test add-in: 这是我用来在测试加载项中创建示例任务的功能:
private void CreateTasks()
{
int i = 1;
Outlook.TaskItem t = null;
Outlook.UserProperties ups = null;
Outlook.UserProperty up = null;
string name = string.Empty;
while (i < 10)
{
name = string.Format("Task {0}", i.ToString());
t = Application.CreateItem(Outlook.OlItemType.olTaskItem);
t.Subject = name;
t.Status = Outlook.OlTaskStatus.olTaskNotStarted;
t.Body = string.Format("Task {0} description", i.ToString());
t.Categories = "Test Task";
t.Importance = Outlook.OlImportance.olImportanceNormal;
t.ActualWork = 0;
t.TotalWork = 5 * 60;
//mimic dates that might come in main add-in
DateTime st = Convert.ToDateTime("12/10/2013");
st = st.AddDays(i);
t.StartDate = st;
DateTime end = Convert.ToDateTime("01/02/2014");
end = end.AddDays(i);
string EP = end.ToShortDateString() + " 5:00:00 PM";
end = Convert.ToDateTime(EP);
t.DueDate = end;
//mimic how we keep track of our items in the main add-in
ups = t.UserProperties;
up = ups.Find("ID");
if (up == null)
{
up = ups.Add("ID", Outlook.OlUserPropertyType.olText);
}
up.Value = string.Format("ID {0}", i.ToString());
//This is where the "The Operation Failed." error occurs on every single task.
try
{
((Outlook._TaskItem)t).Save();
}
catch (Exception ex)
{
//logs message to file
}
//Release objects
if (up != null) Marshal.ReleaseComObject(up);
if (t != null) Marshal.ReleaseComObject(t);
i++;
}
GC.Collect();
}
According to MSDN: 根据MSDN:
Saves the Microsoft Outlook item to the current folder or,
if this is a new item, to the Outlook default folder for the item type.
Does the "non administrator user" have access to this folder? “非管理员用户”是否可以访问此文件夹?
I'd hedge a bet it is something to do with Access permissions. 我敢打赌,这与访问权限有关。 This would be the first place to start.
这将是第一个起点。
Is this in an Exchange mailbox? 这在Exchange邮箱中吗? I've seen this error before when connection to the server becomes spotty.
在连接到服务器之前,我已经看到此错误。 If it is, see if the error occurs if you switch from cached mode to online mode.
如果是,请查看从高速缓存模式切换到在线模式是否会发生错误。 I don't think it's a code issue.
我认为这不是代码问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.