Solved

adding appointment to outlook

Posted on 2010-11-12
5
402 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

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now