Solved

adding appointment to outlook

Posted on 2010-11-12
5
406 Views
Last Modified: 2012-05-10
I'm using this code to insert appointment to outlook and it works fine.

i have several calendars and it seems to add the appointment into the default
calendar, How do i tell it to put the appointment into some of the other calendars i have in outlook?


this is the code i'm using!

Try
            Dim app As Microsoft.Office.Interop.Outlook.Application
            Dim appt As Microsoft.Office.Interop.Outlook.AppointmentItem
            app = New Microsoft.Office.Interop.Outlook.Application
            appt = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem)

            appt.RequiredAttendees = "somebody@domain.com"
            appt.RequiredAttendees = "somebody@domain.com"
            appt.ForceUpdateToAllAttendees = True
            appt.Recipients.Add("somebody@domain.com")
            appt.Subject = "test Subject"
            appt.Body = "Test body"
            appt.Location = "test Office"
            appt.Start = Convert.ToDateTime("11/12/2010 10:00:00 PM")
            appt.End = Convert.ToDateTime("11/12/2010 11:00:00 PM")
            appt.ReminderSet = True
            appt.ReminderMinutesBeforeStart = 15
            appt.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh
            appt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy
            appt.Save()
            appt.Send()

        Catch ex As Exception
            Console.WriteLine(ex.ToString())
        End Try
0
Comment
Question by:jamppi
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 34126082
Hi, jamppi.

To add an appointment to any calendar other than the default use the Add method of the calendar folder's Items collection.  For example, assuming that the object olkCal represents a calendar folder, then

    Set olkAppt = olkCal.Items.Add()
0
 

Author Comment

by:jamppi
ID: 34132895
Hi !!

I'm getting "Public member 'Items' on type 'AppointmentItem' not found."

Could you provide a small snippet for that?

/J
0
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 34133005
The object you're trying to use Items with is the wrong type.  It's an appointment when it should be a folder.  Here's a the snippet.
Dim olkCal As Outlook.MAPIFolder, olkAppt As Outlook.AppointmentItem
'I used the default calendar as an example. You would replace it with a reference to the folder you want to use.'
Set olkCal = Session.GetDefaultFolder(olFolderCalendar)
Set olkAppt = olkCal.Items.Add

Open in new window

0
 

Author Comment

by:jamppi
ID: 34139818
Hi!!

it doesnt work!
i'm getting " 'session' is not declared"

i'm using vsto 2010 and office 2010 could that be the problem?

/J
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34139847
The code I posted is just a fragment, not a complete solution.  It only shows how to add an item to a non-default folder.  You have to integrate it in with your code.  
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question