M
mwolowski
Hello,
I'd like to add tasks, appointments, etc using c# to outlook
For example i added reference
using OutLook = Microsoft.Office.Interop.Outlook;
and the code:
1.
---------------------
OutLook._Application outlookObj = new OutLook.Application();
OutLook.MAPIFolder fldContacts =
(OutLook.MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);
OutLook.ContactItem newContact =
(OutLook.ContactItem)fldContacts.Items.Add(OutLook.OlItemType.olContactItem);
newContact.FirstName = "Ann";
newContact.LastName = "Richardson";
newContact.Email1Address = "(e-mail address removed)";
newContact.Business2TelephoneNumber = "234234-234234";
newContact.BusinessAddress = "California";
newContact.Save();
--------------
or:
2.
----------
Microsoft.Office.Interop.Outlook._Application olApp = new
Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook._NameSpace olNs =
olApp.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.TaskItem task =
(Outlook.TaskItem)olApp.CreateItem(Outlook.OlItemType.olTaskItem);
task.BillingInformation = "http://ann.eu";
task.Subject = "Simple task";
task.Body = "Task description";
task.Status = Outlook.OlTaskStatus.olTaskNotStarted;
task.Importance = Outlook.OlImportance.olImportanceHigh;
task.PercentComplete = 56;
task.Save();
----------
and It doesn't work :/
Has anyone know the simplest way (and correct) to do this?
thx & regards,
ruby
I'd like to add tasks, appointments, etc using c# to outlook
For example i added reference
using OutLook = Microsoft.Office.Interop.Outlook;
and the code:
1.
---------------------
OutLook._Application outlookObj = new OutLook.Application();
OutLook.MAPIFolder fldContacts =
(OutLook.MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);
OutLook.ContactItem newContact =
(OutLook.ContactItem)fldContacts.Items.Add(OutLook.OlItemType.olContactItem);
newContact.FirstName = "Ann";
newContact.LastName = "Richardson";
newContact.Email1Address = "(e-mail address removed)";
newContact.Business2TelephoneNumber = "234234-234234";
newContact.BusinessAddress = "California";
newContact.Save();
--------------
or:
2.
----------
Microsoft.Office.Interop.Outlook._Application olApp = new
Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook._NameSpace olNs =
olApp.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.TaskItem task =
(Outlook.TaskItem)olApp.CreateItem(Outlook.OlItemType.olTaskItem);
task.BillingInformation = "http://ann.eu";
task.Subject = "Simple task";
task.Body = "Task description";
task.Status = Outlook.OlTaskStatus.olTaskNotStarted;
task.Importance = Outlook.OlImportance.olImportanceHigh;
task.PercentComplete = 56;
task.Save();
----------
and It doesn't work :/
Has anyone know the simplest way (and correct) to do this?
thx & regards,
ruby