Hi there,

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

thanks :rolleyes:

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

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
'\\\\\\\\\

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,

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.

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

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

Thread Closed.

commented: Tell this moderator to READ that I asked a question, it was very rude of him / her to say it in a silly way. +0

e

Hi, I'm using your code as a template to send outlook appointment from Word tables. However, I have trouble to
1. assign a start date. "Outlook can not coerce your string" is keeping coming out.
2. Get a weird character at the end of subject line

Could somebody please help?

Here is my code:

Private Sub CommandButton1_Click()
    Dim myOutlook As New Outlook.Application
    Dim i As Long
    Dim myApt As Object
    Dim ctable As Table
    Dim strStart As Range
    Dim mySub As String

    Set ctable = ActiveDocument.Tables(4)
    For r = 2 To ctable.Rows.Count
        If ctable.Cell(r, 2).Range.Text <> Chr(13) & Chr(7) Then
        Set myApt = myOutlook.CreateItem(olAppointmentItem)
        Set strStart = ctable.Cell(r, 4).Range

        With myApt
        .Subject = ctable.Cell(r, 2).Range
        .Location = ctable.Cell(r, 3).Range
        .Start = "7/18/2012"
        .Duration = "60"
        .Body = ctable.Cell(r, 6).Range
        .Recipients.Add ctable.Cell(r, 7).Range
        .MeetingStatus = olMeeting
        .ReminderMinutesBeforeStart = 1440
        .Recipients.ResolveAll
        .Save
        End With
        End If
        Next r
       End Sub

Talk about resurrecting dead threads.

Start a new thread with your problem, some of these users might not even be on Daniweb any more.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.