Add event to outlook calender in VB.NET

I am using the following code to add an event to Outlook calendar. I have added the reference to Outlook (Microsoft Outlook 12.0 Object Library). I went to the security tab in the properties of the folder C:\Program Files\Microsoft Office\Office12 and added permission for ASP.NET account. The project compile dfine but on runtime I am getting the attached error. What other permissions do I need to give?

Case "AddToOtl"
                Dim objOutlook As Outlook.Application
                objOutlook = New Outlook.Application
                Dim objNS As Outlook.NameSpace = objOutlook.Session
                '---------Write to Shared calendar-----------------
                'Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Public Folders")
                Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Personal Folders")
                'objFolder = objFolder.Folders.Item("All Public Folders")
                'objFolder = objFolder.Folders.Item("Boss Calendar")
                objFolder = objFolder.Folders.Item("Calendar")
                '=========Add appointment to calendar=================
                Dim objApp As Outlook.AppointmentItem
                objApp = CType(objFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
                With objApp
                    .Subject = (" Test appointment")
                    .Location = "Main Office"
                    .Body = ("test appointment")
                    .Start = CDate("10.10.2013 10:00") ' NOTICE: This is my locale date format
                    ' Added a reminder
                    .ReminderMinutesBeforeStart = 60
                    .ReminderSet = True
                    ' Added duration
                    .Duration = 120
                    ' Add logged in Windows user
                    .RequiredAttendees = Environment.UserName
                    ' Save first
                    .Save()
                    ' Send to logged in Windows user
                    .Send() ' NOTICE: Outlook security settings may prevent this
                End With
EE.jpg
Angel02Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Asim NazirCommented:
Hi,

Instead of using this approach, better is to implement iCalendar format and simply expose your all feeds/events in this format. It will help you add your events to not only Outlook calendar but also to Google and other calendars that are commonly used today.

For details: http://en.wikipedia.org/wiki/ICalendar

Let me know if you need any other help.
0
Angel02Author Commented:
Thank you for the response.
Please see my attached code. This is what I did to generate an ics file.

But this code opens the calendar file in an appointment window (screenshot attached) and the user has to click "Save & Close" to save the appointment.

Can this step be skipped so that as soon as the user clicks a button, the event is automatically stored to outlook?
ee-code.txt
EE-screenshot.jpg
0
Angel02Author Commented:
I also have to save multiple events at the same time in the calendar. I don't want to open multiple appointment windows like it does now.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Asim NazirCommented:
Hi,

You can do it this way:

1. Create single ics file containing all events.
2. Go to outlook or google calendar and import this ics file.

This will add all events at one and no need to import one by one. I hope it helps.

Asim
0
Angel02Author Commented:
Can you please provide further details of how to do this? Please see attached code. This is what I did. I added another calendar event in the code. When I hit save, it added 2 .ics files as other calendars to my Outlook. Those appointments do not show up on "My Calendar". Please see attached screenshot . You will see several vCalendar[1].ics files towards the left.
ee-code.txt
CalendarEE.jpg
0
Asim NazirCommented:
This and this link should help you further.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.