Question

I have an Outlook add-in that is working successfully for about 100 users. 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." 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. 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. 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();
}

No correct solution

OTHER TIPS

According to 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? 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top