Products Downloads Purchase Support Company
Home : Products : Groupware Features

Groupware Features

Our groupware features include vCard and vCalendar format that are widely used by serious e-mailing and scheduling applications and are therefore a potentially good opportunity to interface your content between systems. For example Microsoft Outlook uses those formats widely for its Contact & Calendar feature.

Contact file reading and writing

The following steps allow you to create a contact file that will be recognized by most contact management applications including Microsoft Outlook. Once the file is created, just double-click on it to have one of the associated applications to open. You can also send this contact file by e-mail or even in an SMS. Most cell phones will handle the format directly and ask the owner if they want to add the contact in their address book!

ShowShow C# code

// We declare some variables to fill the vCard
string firstname = "John";
string lastname = "Doe";
string company = "Acme Corp";
string officePhone = "(555) 12345";
string homePhone = "(555) 12346";
string mobilePhone = "(555) 12347";
string email = "john.doe@example.com"
;
Image photo = Image.FromFile("c:\\johndoe.jpg");
DateTime birthDay = new DateTime(1967, 5, 3);

vCard card = new vCard();

card.Name.GivenName = "John";
card.Name.FamilyName = "Doe";
card.Organization.Add("Acme Corp");
card.TelephoneNumbers.Add("(555) 12345", TelephoneNumberSingleType.Work);
card.TelephoneNumbers.Add("(555) 12346", TelephoneNumberSingleType.Home);

card.TelephoneNumbers.Add("(555) 12347", TelephoneNumberSingleType.Cellular);
card.EmailAddresses.Add("john.doe@example.com");
card.Birthday = new DateTime(1967, 5, 3);

Image photo = Image.FromFile("c:\\johndoe.jpg");
MemoryStream stream = new MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
card.Photo = stream.ToArray();

card.SaveToFile("c:\\johndoe.vcf");

 

You can safely read vCard files sent by other applications, including cell phones:

ShowShow C# code

// We declare some variables to fill from the vCard
string firstname = string.Empty;
string lastname = string.Empty;
string company = string.Empty;
string officePhone = string.Empty;
string homePhone = string.Empty;
string mobilePhone = string.Empty;
string email = string.Empty;
Image photo = null;
DateTime birthDay = DateTime.Now;

// We read the contact file
vCard vcard = vCard.LoadFromFile("c:\\contact.vcf");

// First and lastname, called Given Name and Family Name in vCard specifications
firstname = vcard.Name.GivenName;
lastname = vcard.Name.FamilyName;

// Company, called Organisation in vCard specifications
if (vcard.Organization.Count > 0)
    company = vcard.Organization[0].ToString();

// Telephone numbers
foreach (TelephoneNumber telephoneNumber in vcard.TelephoneNumbers)
{
    if (telephoneNumber.IsWork)
        officePhone = telephoneNumber.Number;
    else if (telephoneNumber.IsHome)
        homePhone = telephoneNumber.Number;
    else if (telephoneNumber.IsCellular)
        mobilePhone = telephoneNumber.Number;
}

// Email address (we take the first one)
if (vcard.EmailAddresses.Count > 0)
    email = vcard.EmailAddresses[0].Address;

birthDay = vcard.Birthday;

if (vcard.Photo != null)
{
    MemoryStream stream = new MemoryStream(vcard.Photo);
    photo = Image.FromStream(stream);
}

Calendar event reading and writing

Having the ability to manage the calendar items can be really useful for an application as you are able to create, send and receive meeting requests or assignments. Here is an example to create a calendar item:

ShowShow C# code

vCalendar calendar = new vCalendar();
vEvent newEvent = new vEvent();
newEvent.Summary = "Meeting about the new release";
newEvent.Location = "Meeting Room 1st Floor";
newEvent.Start = new DateTime(2007, 4, 4, 11, 00, 00);
newEvent.End = newEvent.Start.AddHours(1);
calendar.Events.Add(newEvent);
calendar.SaveToFile("c:\\meetingRequest.ics");

It is also very simple to read it:

ShowShow C# code

string summary, location;
DateTime startDate, endDate;

vCalendar calendar = vCalendar.LoadFromFile("c:\\meetingRequest.ics");

if (calendar.Events.Count > 0)
{
    vEvent fEvent = calendar.Events[0];
    summary = fEvent.Summary;
    location = fEvent.Location;
    startDate = fEvent.Start;
    endDate = fEvent.End;
}
else
    MessageBox.Show("No events found in the vCalendar file.");

 

 

Copyright © 2000-2007 Active Up - All Rights Reserved - Privacy Policy