Creating new appoitment in MS Outlook by VB.net RRS feed

  • Question

  • Hello,

    I am trying to create the program for shift workers and the output should be the appointment in MS Outlook. If event is shorter than 24 hour is created in calendar "gap" at midnight (please see added picture http://2i.cz/e789a78d5e ). If event is longer than 24 hours everything is OK.

    I use Outlook 2010 Czech version and VB.net 2010.

    Here is a code:

    Dim Outlook As New Microsoft.Office.Interop.Outlook.Application()
            Dim App As Microsoft.Office.Interop.Outlook.AppointmentItem
     	App = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem)
            App.Start = CDate("18.7.2012 4:00 PM")
            App.Duration = 12 * 60
            App.Subject = "eee"
            App = Nothing

    Finding the better solution I lost a lot of time and I am really depressed :)

    • Moved by Mark Liu-lxf Monday, July 16, 2012 7:31 AM (From:Visual Basic General)
    Sunday, July 15, 2012 3:54 PM

All replies

  • here is a piece of code from MSDN to create a new appointment for a full day. It was in C# and I converted into VB.Net: http://msdn.microsoft.com/en-us/library/ff184629

    Private Sub AllDayEventExample()
    	Dim appt As Outlook.AppointmentItem = TryCast(Application.CreateItem(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
    	appt.Subject = "Developer's Conference"
    	appt.AllDayEvent = True
    	appt.Start = DateTime.Parse("6/11/2007 12:00 AM")
    	appt.[End] = DateTime.Parse("6/16/2007 12:00 AM")
    End Sub

    Sunday, July 15, 2012 11:03 PM
  • Hi Fernandez2012,

    Thank you for posting in the MSDN Forum.

    Could please post your picture here? I can open the link you provided but cannot see any pictures.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, July 26, 2012 10:18 AM
  • Dear Quist Zhang,

    thank you for your reaction. Here is a picture:

    Saturday, July 28, 2012 5:47 PM
  • Dear Bhaskar Shrestha,

    Thank you for your advice. I tried your instruction, but problem is the date in format month/day/year ("6/16/2007 12:00 AM") does not work and it is finished by error.

    Maybe is the problem that outlook is awaiting date in format month/day/year but I may use only this format day/month/year (because of that I have windows 7 czech version).

    Saturday, July 28, 2012 6:13 PM