The Windows Mobile Tasks area (accessible through Programs | Tasks) allows you to keep track of your personal tasks. You can also synchronize the sales force tasks with the tasks in this area.
Each Windows Mobile Task item contains a unique ItemId
property value. By retrieving these values and saving them together in the AccountTasks
table, you can associate each Windows Mobile Task item with a task in your sales force application.
Let's take a look now at how you can create the code to access Windows Mobile tasks. Through the same OutlookSession
class, you can find a particular Windows Mobile Task items using its ItemId
property.
using Microsoft.WindowsMobile.PocketOutlook; public string SyncToWindowsMobileTasks(string taskSubject, string taskDescription, DateTime taskDueDate, string taskID) { OutlookSession _outlookapp = new OutlookSession(); PropertyDescriptor _task; int _taskIndex; Task _taskItem; _task = TypeDescriptor.GetProperties(typeof(Task))["ItemId"]; _taskIndex = _outlookapp.Tasks.Items.Find(_task, taskID);
If a task with the matching item ID cannot be found, you will need to create a new task. However, if a task with a matching ID is found, you must then update the subject, body, and due date of that task item with the latest data from your sales force application.
if (_taskIndex == - 1) { _taskItem = new Task(); _taskItem.Body = taskDescription; _taskItem.Subject = taskSubject; _taskItem.DueDate = taskDueDate; _taskItem.ReminderDialog = true; _taskItem.ReminderRepeat = true; _taskItem.ReminderSound = true; _taskItem.ReminderVibrate = true; _outlookapp.Tasks.Items.Add(_taskItem); } else { _taskItem = _outlookapp.Tasks.Items[_taskIndex]; _taskItem.Body = taskDescription; _taskItem.Subject = taskSubject; _taskItem.DueDate = taskDueDate; _taskItem.Update(); } return _taskItem.ItemId.ToString(); }
A good place to call this function would be in the btnSave_Click()
function in your AccountViewer
form. You need to iterate through all the task items and run the SyncToWindowsMobileTasks()
function on each task. This will be left to you as an exercise.
18.219.171.52