Integrating asp.net 2.0 and outlook 2003

  • Thread starter Thread starter mwolowski
  • Start date Start date
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
 
Did you receive an error? If so, what is the error?

Are you running this server-side? Which outlook are you expecting it to add
to? I ask this because some people who have tried this have expected, for
some unkown reason, that this server-side code would add appointments into
the client's outlook.

It could be that the ASPNET user account, which is what ASP runs through,
won't have permissions to access Outlook and/or the pst file that the items
will be added to.
 
using OutLook = Microsoft.Office.Interop.Outlook;
OutLook._Application outlookObj = new OutLook.Application();

Microsoft strongly disadvises server-side Office automation to the extent
where they won't actually support any application which uses it:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

What that means, basically, is that if you go down that route, you're on
your own...

Presumably, you have actually installed Outlook on your webserver...?
Has anyone know the simplest way (and correct) to do this?

I *believe* this can be achieved through ActiveDirectory, though I haven't
tried it myself. I'd suggest posting your question in
microsoft.public.adsi.general, mentioning specifically that you need to use
ASP.NET...
 
When i was debugging it i got:
----------------
An exception of type 'System.Runtime.InteropServices.COMException'
occurred in ControllingWebUI.DLL but was not handled in user code

Additional information: Retrieving the COM class factory for component
with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the
following error: 80010001.
 
Back
Top