Solved

adding appointment to outlook

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
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…
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: …

706 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

17 Experts available now in Live!

Get 1:1 Help Now