Geeks With Blogs
The Trials and Tribulations of a Self-Taught Developer By Justin Russell

I recently began development of a new SharePoint (WSS) workflow. The idea is pretty straightforward. When an item is added to the calendar, the workflow will send out a reminder e-mail 24 hours prior to the Start Time. The e-mail will include the details of the appointment and an iCalender (.ics) attachment so people can add the appointment to their e-mail client calendar.

Seems pretty simple, right? Well, there are a few pitfalls I've encountered along the way that I'd like to share for others in a similar situation.

First - the SharePoint SendEmail action does not allow for attachments, so you're gonna have to use the .NET method for sending mail. There are already lots of great posts out there on sending e-mail with attachments from a SharePoint workflow so I'm not going to cover it again. The challenge I ran into was adding the recipients e-mail addresses. I found some examples of this too but none of them worked for me. I ended up mashing together some different techniques and this is what I came up with:

            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(smtpFrom);
            mailMessage.Subject = "Message Subject";
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = strBody;

            SPSite oSiteCollection = new SPSite("Http://");
            SPWeb currentWeb = oSiteCollection.OpenWeb();
            using (SPWeb oWebsite = oSiteCollection.AllWebs["ChangeMan"])
                foreach (SPUser oUser in oWebsite.AllUsers)
                    if (oUser.Email.ToString().Length > 1)
                        mailMessage.To.Add(new MailAddress(oUser.Email.ToString()));

I apologize for the lack of comments and links to the resources I used. If portions of the code look familiar please let me know and I'll be happy to give you credit.

The second problem I encountered was with the iCal attachment. The time zone would always be wrong in my Outlook, even though when opening the attachment in Notepad the times were correct. I toyed with a bunch of different methods to create the attachment then I finally stumbled upon this little gem:

Specifically, this section:

The difference between a floating time and an UTC time is one letter. This is an UTC time


And this a floating time


The UTC time has an extra Z.

I haven't seen this information anywhere else (no, I didn't read the entire RFC) so I want to give thanks to the author.

Posted on Thursday, January 24, 2008 3:32 AM | Back to top

Comments on this post: iCalendar Time Zone

# re: iCalendar Time Zone
Requesting Gravatar...
Just a stupid FYI for you...the "Z" actually does have a meaning! It stands for the "Zulu" time zone. In the military and most maritime applications, time is stated as "1300 Hours Minus 8 Tango"...meaning it is 1pm and we are in the time zome GMT-8 or "Tango". There are 24 time zones in the world..."Zulu" is GMT...."Tango" is PST...and so on and so forth! And there's your military lesson of the day...from one SharePoint Designer to another!
Left by Ryan King on Apr 30, 2009 1:03 AM

Your comment:
 (will show your gravatar)

Copyright © Justin Russell | Powered by: