depicus

  just another nerd on the interweb…



  • home
  • gallery
  • play page
  • privacy
  • support
  • videos
  • what is depicus

Create a vCal in dot.net

Author: The Man



I am in the process of updating a project we started 6 years ago. One of the functions was to add a diary event to Outlook. At the time there was a simple method of automation to add events directly to Outlook but in this day and age there are two problems with this approach

1. Automation of other applications is becoming more and more complex, having to jump through security hoops and then explain that to end users is just to much hard work.

2. Outlook may be king now but providing solutions that work with multiple suppliers software is the way forward.

This snippet now allows us to create a calendar event and open so the user can check and confirm, not the neatest solution but it works.

View Code VB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Dim myICal As New StreamWriter("event.vcs")
Dim sDate As Date = Convert.ToDateTime(edtOn.Text + " " + edtAT.Text)
Dim eDate As Date = DateAdd(DateInterval.Hour, 1, Convert.ToDateTime(edtOn.Text + " " + edtAT.Text))
Dim myLocation As String = lblView.Text
Dim mySubject As String = lblFor.Text
Dim myDescription As String = "Event details: Check server is started"
 
'Create the vCal
myICal.WriteLine("BEGIN:VCALENDAR")
myICal.WriteLine("PRODID:-//Digital Wired Limited.//Agency Manager Professional//EN")
myICal.WriteLine("BEGIN:VEVENT")
myICal.WriteLine("DTSTART:" & sDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"))
myICal.WriteLine("DTEND:" & eDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"))
myICal.WriteLine("LOCATION:" & myLocation)
myICal.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & myDescription)
myICal.WriteLine("SUMMARY:" & mySubject)
myICal.WriteLine("PRIORITY:2")
myICal.WriteLine("END:VEVENT")
myICal.WriteLine("END:VCALENDAR")
myICal.Close()
 
System.Diagnostics.Process.Start("event.vcs")

That’s it, not pretty but functional.

Tweet

Tags: Code, DotNet, Outlook, vb.net, Windows

This entry was posted on Tuesday, March 2nd, 2010 at 8:43 pm and is filed under Software Development. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.

  • how i pay the bills

  • depicus in africa

    depicus in africa
  • my charity page

    JustGiving - Sponsor me now!
  • friends

    • Agency Manager
    • AllClear Travel
    • Climbing Tikes
    • Globe Bloggers
    • Marchday
    • The Travel Toad
  • gallery

    IMG_4230 IMG_3221 IMG_4297 IMG_4636
  • videos

    Vimeo

    YouTube
  • twitter

    • No public Twitter messages.
  • recent comments

    • john coull: correction to above, its www.oakley-ukstore.com
    • john coull: they are at it again. adverts on facebook . they are being hosted by enotch.com on ip address...
    • steve: The site are selling £120+ Oakley sun glasses for £13.00 I think its safe to say they may be either...
    • rob: have received a pair of glasses not what ive ordered they are now telling me the ones ive ordered are out of...
    • phil: hi i have purchased some (stupidly),not arrived yet, will they arrive/will they be fake/plz help

Copyright © - depicus | Entries (RSS) | Comments (RSS)

WordPress theme butchered and amended by me.