By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,660 Members | 1,953 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,660 IT Pros & Developers. It's quick & easy.

Integrating asp.net 2.0 and outlook 2003

P: n/a
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.GetDefaultF older(OutLook.OlDefaultFolders.olFolderContacts);

OutLook.ContactItem newContact =
(OutLook.ContactItem)fldContacts.Items.Add(OutLook .OlItemType.olContactItem);
newContact.FirstName = "Ann";
newContact.LastName = "Richardson";
newContact.Email1Address = "an*@ann.ue";
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.OlItemT ype.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

Jan 8 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"mwolowski" <mw*******@gmail.comwrote in message
news:11**********************@s80g2000cwa.googlegr oups.com...
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.GetDefaultF older(OutLook.OlDefaultFolders.olFolderContacts);

OutLook.ContactItem newContact =
(OutLook.ContactItem)fldContacts.Items.Add(OutLook .OlItemType.olContactItem);
newContact.FirstName = "Ann";
newContact.LastName = "Richardson";
newContact.Email1Address = "an*@ann.ue";
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.OlItemT ype.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

Jan 8 '07 #2

P: n/a
"mwolowski" <mw*******@gmail.comwrote in message
news:11**********************@s80g2000cwa.googlegr oups.com...
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...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...
Jan 8 '07 #3

P: n/a
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.
--------------
I use Outlook 2003 and Acitive Directory.

Mark Fitzpatrick napisal(a):
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.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"mwolowski" <mw*******@gmail.comwrote in message
news:11**********************@s80g2000cwa.googlegr oups.com...
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.GetDefaultF older(OutLook.OlDefaultFolders.olFolderContacts);

OutLook.ContactItem newContact =
(OutLook.ContactItem)fldContacts.Items.Add(OutLook .OlItemType.olContactItem);
newContact.FirstName = "Ann";
newContact.LastName = "Richardson";
newContact.Email1Address = "an*@ann.ue";
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.OlItemT ype.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
Jan 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.