?
Solved

adding appointment to outlook

Posted on 2010-11-12
5
Medium Priority
?
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

777 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