954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

create an appointment in outlook using VB.NET

Hi there,

Does anyone knows ho to create an appointment in outlook using VB.net ?

thanks :rolleyes:

yoavgold
Newbie Poster
6 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

One way is to use a CSV or CAL file, genereate it on the fly and send it as an atachment to someone or create a dynamic link on a web page for them to click on.

Tlaloc

TlalocTev
Newbie Poster
1 post since Jul 2006
Reputation Points: 10
Solved Threads: 0
 

Hi there,

Does anyone knows ho to create an appointment in outlook using VB.net ?

thanks :rolleyes:

Dim objOutlook As Outlook.Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook.NameSpace = objOutlook.Session

'---------Write to Shared calendar-----------------
Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Public Folders")
objFolder = objFolder.Folders.Item("All Public Folders")
objFolder = objFolder.Folders.Item("Boss Calendar")

'=========Add appointment to calendar=================
Dim objApp As Outlook.AppointmentItem
objApp = objFolder.Items(Outlook.OlItemType.olAppointmentItem)

With objApp
.Subject = (" Test appointment")
.Location = "Main Office"
.Body = ("test appointment")
.Start = ("1:30pm 11/21/2007")
.Save()
End With
'\\\\\\\\\

slavedogg
Newbie Poster
13 posts since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

I tried the code above but I am getting a compiler error at
objApp = objFolder.Items(Outlook.OlItemType.olAppointmentItem)

Intellisense says that
Interface "outlook.item" cannot be indexed because it has not default property.

I maybe should know this but your help is greatly appreciated.

Also, say I want to add the appointment in the agenda of the logged in Windows user. How do I do this?

Many thanks in advance,

cgig
Newbie Poster
1 post since May 2009
Reputation Points: 10
Solved Threads: 0
 
Intellisense says that Interface "outlook.item" cannot be indexed because it has not default property.

I believe it said "outlook.items". Yes, you have to use Item property of Outlook.Items collection.

I partly rewrote the OP's code. Simply commented out some lines, added few properties for the appointment and fixed the error mentioned above

Dim objOutlook As Outlook.Application
objOutlook = New Outlook.Application()
Dim objNS As Outlook.NameSpace = objOutlook.Session

'---------Write to Shared calendar-----------------

'Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Public Folders")
Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("Personal Folders")

'objFolder = objFolder.Folders.Item("All Public Folders")
'objFolder = objFolder.Folders.Item("Boss Calendar")
objFolder = objFolder.Folders.Item("Calendar")

'=========Add appointment to calendar=================
Dim objApp As Outlook.AppointmentItem
objApp = CType(objFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)

With objApp
  .Subject = (" Test appointment")
  .Location = "Main Office"
  .Body = ("test appointment")
  .Start = CDate("19.5.2009 10:00") ' NOTICE: This is my locale date format
  ' Added a reminder
  .ReminderMinutesBeforeStart = 60
  .ReminderSet = True
  ' Added duration
  .Duration = 120
  ' Add logged in Windows user
  .RequiredAttendees = Environment.UserName
  ' Save first
  .Save()
  ' Send to logged in Windows user
  .Send() ' NOTICE: Outlook security settings may prevent this
End With
'\\\\\\\\\


If you don't need to invite anyone i.e. just add an appointment in your own calendar, remove lines .RequiredAttendees = Environment.UserName and .Send() . I wasn't able to fully test appointment sending but I think it's very close to what it should be.

Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
 

Thank you, really liked the code and it helped me as well. Can I use it while developing an add-in too?

fwd079
Newbie Poster
2 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

I'm glad you got it helpful. If you want to ask question, start your own thread.

Thread Closed.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You