jamppi
asked on
adding appointment to outlook
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.O utlook.App lication
Dim appt As Microsoft.Office.Interop.O utlook.App ointmentIt em
app = New Microsoft.Office.Interop.O utlook.App lication
appt = app.CreateItem(Microsoft.O ffice.Inte rop.Outloo k.OlItemTy pe.olAppoi ntmentItem )
appt.RequiredAttendees = "somebody@domain.com"
appt.RequiredAttendees = "somebody@domain.com"
appt.ForceUpdateToAllAtten dees = True
appt.Recipients.Add("someb ody@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.ReminderMinutesBefore Start = 15
appt.Importance = Microsoft.Office.Interop.O utlook.OlI mportance. olImportan ceHigh
appt.BusyStatus = Microsoft.Office.Interop.O utlook.OlB usyStatus. olBusy
appt.Save()
appt.Send()
Catch ex As Exception
Console.WriteLine(ex.ToStr ing())
End Try
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.O
Dim appt As Microsoft.Office.Interop.O
app = New Microsoft.Office.Interop.O
appt = app.CreateItem(Microsoft.O
appt.RequiredAttendees = "somebody@domain.com"
appt.RequiredAttendees = "somebody@domain.com"
appt.ForceUpdateToAllAtten
appt.Recipients.Add("someb
appt.Subject = "test Subject"
appt.Body = "Test body"
appt.Location = "test Office"
appt.Start = Convert.ToDateTime("11/12/
appt.End = Convert.ToDateTime("11/12/
appt.ReminderSet = True
appt.ReminderMinutesBefore
appt.Importance = Microsoft.Office.Interop.O
appt.BusyStatus = Microsoft.Office.Interop.O
appt.Save()
appt.Send()
Catch ex As Exception
Console.WriteLine(ex.ToStr
End Try
ASKER
Hi !!
I'm getting "Public member 'Items' on type 'AppointmentItem' not found."
Could you provide a small snippet for that?
/J
I'm getting "Public member 'Items' on type 'AppointmentItem' not found."
Could you provide a small snippet for that?
/J
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
it doesnt work!
i'm getting " 'session' is not declared"
i'm using vsto 2010 and office 2010 could that be the problem?
/J
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.
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()