I had to create a Appointment by parsing through the database and then sending a particular guy a appointment which would remind him about the appointment approx 15 mins before the scheduled time. The same way in which Outlook Appointment functions.
Searching a bit, I found a way to utilise the Outlook Object library and send appointments by creating appointment objects and sending them.
Was damn happy with the outcome till I ran the program and then I saw the dreaded Prompt.
Due to a security protocol of MS ( Security patch ),everytime a code tried to create a instance of the Outlook object library and use it to send a mail, appoinment etc. it prompts the user with a dialog box asking him whether to allow access or to reject access to the program trying to use outlook object.
Now, since I was writing the code as a part of Windows Service there was no question of the prompt and letting the user click on the buttons every time code would send a appointment. Hence searching a bit on the outlooks Way of Forwarding Appoinments in ICalendar format and also the great Google 🙂
Found out a way of creating a ICalendar format Appointment and sending it accorss to the attendee.
Here is a way in which you can send appointments via ICalendar format through code and not using the Outlook Object library (This is a very basic version of the way and does not involve much exception handling,and doesnt take care of nth case , explore a bit on that front :))
| /// Sends a appointment in a ICalendar format.
/// Date of the meeting.
/// Start time of the meeting.
/// End time of the meeting.
/// Subject of the Meeting.
/// Name of the attendees for the meeting.
/// Email addresses of the attendess,seperated by ;.
/// Email address of the organizer.
/// Path of the current working directory.
/// bool indicating the status of the method call.
/// Need to give the current working directory path as the meeting request is
/// stored in the current directory before attaching it to the mail.
/// Will be adding more customisations in the parameters. and a class to encapsulate the parameter passing.
///“Discuss demo issues”,
///“we need to have this meeting to discuss certain issues related to demo.”,
///“Conference room 1st floor”,
///“c:\\prj\\temp”); currently requires the filepath to store the ICalendar file in.
public bool SendAppoinment(string startDate,
const string c_strTimeFormat = “yyyyMMdd\\THHmmss\\Z”;
// VCalendar Format.
DateTime dtmStartDate = DateTime.Parse(startDate.ToString());
filePath += “\\” + subject+ “.ics”;
// write a line of text to the file
// close the stream
// Create object for sending mails
MailMessage mail = new MailMessage();