locked
Download Calendar Events to Outlook RRS feed

  • Question

  • User1479750397 posted
    Anyone got the download of calendar events to work?  If I save the file and then open it all is good.  If I try and open it directly without saving it, it fails.
    Thursday, March 23, 2006 2:08 PM

All replies

  • User380413204 posted

    Hi,

    No solution, sorry.

    But just to say I got the same problem.

    Lex

    Friday, March 24, 2006 5:45 AM
  • User1275632693 posted

    Same here, but certainly something that can be added to a complete Checklist.

    I am thinking we should Open a Thread and see who is working on What.

     

     

    Sunday, March 26, 2006 10:34 PM
  • User-332238837 posted
     I have the following code which does work if that is of any help?
    Public Class vCalendar
    #Region "vCalendar Class"
    	Public Events As vEvents
    
    	Public Overrides Function ToString() As String
    		Dim result As New System.Text.StringBuilder()
    		result.AppendFormat("BEGIN:VCALENDAR{0}", System.Environment.NewLine)
    		'The following two lines seem to be required by Outlook to get the alarm settings
    
    		result.AppendFormat("VERSION:2.0{0}", System.Environment.NewLine)
    		result.AppendFormat("METHOD:PUBLISH{0}", System.Environment.NewLine)
    		Dim item As vEvent
    		For Each item In Events
    			result.Append(item.ToString())
    		Next
    		result.AppendFormat("END:VCALENDAR{0}", System.Environment.NewLine)
    		Return result.ToString
    	End Function
    
    	Public Sub New(ByVal Value As vEvent)
    		Me.Events = New vEvents()
    		Me.Events.Add(Value)
    	End Sub
    
    	Public Sub New()
    		Me.Events = New vEvents()
    	End Sub
    #End Region
    
    #Region "vAlarm Class"
    	Public Class vAlarm
    		Public Trigger As TimeSpan		'Amount of time before event to display alarm
    
    		Public Action As String		 'Action to take to notify user of alarm
    
    		Public Description As String		  'Description of the alarm
    
    
    		Public Sub New()
    			Trigger = TimeSpan.FromDays(1)
    			Action = "DISPLAY"
    			Description = "Reminder"
    		End Sub
    
    		Public Sub New(ByVal SetTrigger As TimeSpan)
    			Trigger = SetTrigger
    			Action = "DISPLAY"
    			Description = "Reminder"
    		End Sub
    
    		Public Sub New(ByVal SetTrigger As TimeSpan, ByVal SetAction As String, ByVal SetDescription As String)
    			Trigger = SetTrigger
    			Action = SetAction
    			Description = SetDescription
    		End Sub
    
    		Public Overrides Function ToString() As String
    			Dim result As New System.Text.StringBuilder()
    			result.AppendFormat("BEGIN:VALARM{0}", System.Environment.NewLine)
    			result.AppendFormat("TRIGGER:P{0}DT{1}H{2}M{3}", Trigger.Days, Trigger.Hours, Trigger.Minutes, System.Environment.NewLine)
    			result.AppendFormat("ACTION:{0}{1}", Action, System.Environment.NewLine)
    			result.AppendFormat("DESCRIPTION:{0}{1}", Description, System.Environment.NewLine)
    			result.AppendFormat("END:VALARM{0}", System.Environment.NewLine)
    			Return result.ToString
    		End Function
    	End Class
    #End Region
    
    #Region "vEvent Class"
    	Public Class vEvent
    		Public UID As String		  'Unique identifier for the event
    
    		Public DTStart As Date		'Start date of event.  Will be automatically converted to GMT
    
    		Public DTEnd As Date		 'End date of event.  Will be automatically converted to GMT
    
    		Public DTStamp As Date		'Timestamp.  Will be automatically converted to GMT
    
    		Public Summary As String		  'Summary/Subject of event
    
    		Public Organizer As String		'Can be mailto: url or just a name
    
    		Public Location As String
    		Public Description As String
    		Public URL As String
    		Public Alarms As vAlarms		'Alarms needed for this event
    
    
    		Public Overrides Function ToString() As String
    			Dim result As New System.Text.StringBuilder()
    			result.AppendFormat("BEGIN:VEVENT{0}", System.Environment.NewLine)
    			result.AppendFormat("UID:{0}{1}", UID, System.Environment.NewLine)
    			result.AppendFormat("SUMMARY:{0}{1}", Summary, System.Environment.NewLine)
    			result.AppendFormat("ORGANIZER:{0}{1}", Organizer, System.Environment.NewLine)
    			result.AppendFormat("LOCATION:{0}{1}", Location, System.Environment.NewLine)
    			result.AppendFormat("DTSTART:{0}{1}", DTStart.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"), System.Environment.NewLine)
    			result.AppendFormat("DTEND:{0}{1}", DTEnd.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"), System.Environment.NewLine)
    			result.AppendFormat("DTSTAMP:{0}{1}", Now.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z"), System.Environment.NewLine)
    			result.AppendFormat("DESCRIPTION:{0}{1}", Description, System.Environment.NewLine)
    			If URL.Length > 0 Then result.AppendFormat("URL:{0}{1}", URL, System.Environment.NewLine)
    			Dim item As vAlarm
    			For Each item In Alarms
    				result.Append(item.ToString())
    			Next
    			result.AppendFormat("END:VEVENT{0}", System.Environment.NewLine)
    			Return result.ToString
    		End Function
    
    		Public Sub New()
    			Me.Alarms = New vAlarms()
    		End Sub
    	End Class
    #End Region
    
    #Region "vAlarms Class"
    	Public Class vAlarms
    		' The first thing to do when building a CollectionBase class is to inherit from System.Collections.CollectionBase
    
    		Inherits System.Collections.CollectionBase
    
    		Public Overloads Function Add(ByVal Value As vAlarm) As vAlarm
    			' After you inherit the CollectionBase class, you can access an intrinsic object
    			' called InnerList that represents your collection. InnerList is of type ArrayList.
    
    			Me.InnerList.Add(Value)
    			Return Value
    		End Function
    
    		Public Overloads Function Item(ByVal Index As Integer) As vAlarm
    			' To retrieve an item from the InnerList, pass the index of that item to the .Item property.
    
    			Return CType(Me.InnerList.Item(Index), vAlarm)
    		End Function
    
    		Public Overloads Sub Remove(ByVal Index As Integer)
    			' This Remove expects an index.
    
    			Dim cust As vAlarm
    
    			cust = CType(Me.InnerList.Item(Index), vAlarm)
    			If Not cust Is Nothing Then
    				Me.InnerList.Remove(cust)
    			End If
    		End Sub
    
    	End Class
    #End Region
    
    #Region "vEvents Class"
    	Public Class vEvents
    		' The first thing to do when building a CollectionBase class is to inherit from System.Collections.CollectionBase
    
    		Inherits System.Collections.CollectionBase
    
    		Public Overloads Function Add(ByVal Value As vEvent) As vEvent
    			' After you inherit the CollectionBase class, you can access an intrinsic object
    			' called InnerList that represents your collection. InnerList is of type ArrayList.
    
    			Me.InnerList.Add(Value)
    			Return Value
    		End Function
    
    		Public Overloads Function Item(ByVal Index As Integer) As vEvent
    			' To retrieve an item from the InnerList, pass the index of that item to the .Item property.
    
    			Return CType(Me.InnerList.Item(Index), vEvent)
    		End Function
    
    		Public Overloads Sub Remove(ByVal Index As Integer)
    			' This Remove expects an index.
    
    			Dim cust As vEvent
    
    			cust = CType(Me.InnerList.Item(Index), vEvent)
    			If Not cust Is Nothing Then
    				Me.InnerList.Remove(cust)
    			End If
    		End Sub
    	End Class
    #End Region
    End Class
    
     
    Sunday, April 16, 2006 1:09 PM
  • User654902800 posted

    Try this - in Events_Download.ashx, after this line in method ProcessRequest()

       response.ContentType = "text/calendar"

    add these two

       response.AppendHeader("Filename", "event.ics")
       response.AppendHeader(
    "Content-Disposition", "attachment;filename=event.ics")

    and that should convince IE that it's an ical file and let you download it.

    Cheers,

    Tuesday, April 18, 2006 6:52 PM
  • User-1093854538 posted

    Tried, but it did not work for me.

    After:    response.ContentType = "text/calendar"

    add these two

       response.AppendHeader("Filename", "event.ics")
       response.AppendHeader(
    "Content-Disposition", "attachment;filename=event.ics")

    and that should convince IE that it's an ical file and let you download it.

     

    Got the open/save AS dialog box but when choosing open it did not add it to my outlook calendar.

    error was :

    The Operation failed  An object could not be found.

    Tuesday, April 18, 2006 8:02 PM
  • User654902800 posted

    Well, I love a challenge :) I confess I just got it to where it would download properly and didn't try to actually open it, so mea culpa.

    We have to work around a couple of weird behaviours here. So...

    In Events_Download, change the ProcessRequest() to this:

        Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
            Dim response As Web.HttpResponse = context.Response
            Dim request As Web.HttpRequest = context.Request
            Dim EventID As Integer = CInt(request.QueryString("EventID"))
            ' make a unique "filename" for this event
            ' so it can be cached without trouble

            Dim Filename As String = EventID.ToString() & "event.ics"
            response.BufferOutput = True
            response.ContentType = "text/calendar"
            response.AppendHeader("Filename", Filename)
            response.AppendHeader("Content-Disposition", "attachment;filename=" & Filename)
            ' allow it to be cached so IE can save it where Outlook will find it
            response.Cache.SetCacheability(HttpCacheability.Public)
            Dim viewurl As New Uri(context.Request.Url, "Events_view.aspx?Eventid=" & EventID)
            writeCalEntry(eventid, response.Output, viewurl.ToString)
            response.End()
        End Sub

    That fixes the original problem except for one thing, the add event code will allow you to create an event that has an end time that comes before the start time. So when you make an event for tomorrow, unless you are paying attention, that event will end today, and Outlook doesn't like that at all, so we have to fix that code as well...

    In DurationPicker.ascx, change the Property endDateTime() so it looks like this:

        Public Property endDateTime() As Date
            Get
                Dim foo As Date = dp2.SelectedDate.Add(tp2.SelectedTime.TimeOfDay)
                ' make sure we are at least equal to startDateTime, and not before it
                If foo < startDateTime() Then
                    Return startDateTime
                End If
                Return foo
            End Get
            Set(ByVal value As Date)
                dp2.SelectedDate = value
                tp2.SelectedTime = value
            End Set
        End Property

    Now you can't make an event that defies Einstein (Newton is a different story, for an anti-gravity control see... oh never mind).

    If you already have some events posted that have end times that occur before the start time, well, you should maybe edit them so they will open properly in Outlook.

    Let me know if this handles it for you!

    -----

    Note: there is one case where an event ends before it begins, when you fly from Sydney to San Francisco, because of the dateline, you arrive half an hour before you left :)

    186,000 miles per second - it's the Law.

    Tuesday, April 18, 2006 11:20 PM
  • User380413204 posted

    On Saturday I will travel (with anti-gravity control) from Rotterdam 7:20 to London ETA 07:10

    But seriously,

    I'm at work now, but eager to try this out as soon as I get home.

    Lex

     

    Wednesday, April 19, 2006 6:38 AM
  • User380413204 posted

    Hi,

    Not quite yet, I get this:

    Index and length must refer to a location within the string.
    Parameter name: length

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    Parameter name: length

    Source Error:

    Line 148:      
    Line 149:        Do While offset < sb.Length
    Line 150:            Dim pos As Integer = sb.ToString(offset - 5, 10).IndexOf("=0D=0A")
    Line 151:            If pos = -1 Then
    Line 152:                'Account for the string at the end of where we want to insert

    Regards,

    Lex

    Wednesday, April 19, 2006 10:12 AM
  • User380413204 posted

    Hi,

    Forget the last post, it works great!

    Thanks,

    Lex

     

    N.B.

    He since you like a good challenge, how about you joining in on integrating the ICTN forum ??

    (just kiddin, well ehhh...)

     

    Wednesday, April 19, 2006 10:26 AM
  • User1275632693 posted

    What happens if someone does not use outlook?

    What does the control do/reply when you try to drop it into you calendar but you dont have Outlook?

    Hmm.. personally I don't like Outlook or Outlook Express but I suppose it is another fait accompli in so far as it is engrained in windows.

     

     

    Wednesday, April 19, 2006 10:40 AM
  • User654902800 posted

    iCal is not just an Outlook thing - it's a calendar thing - see

    http://events.bcs.rochester.edu/icalexp.aspx

    Wednesday, April 19, 2006 1:37 PM
  • User-903483237 posted

    Well, I love a challenge :) I confess I just got it to where it would download properly and didn't try to actually open it, so mea culpa.

    We have to work around a couple of weird behaviours here. So...

    In Events_Download, change the ProcessRequest() to this:

        Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
            Dim response As Web.HttpResponse = context.Response
            Dim request As Web.HttpRequest = context.Request
            Dim EventID As Integer = CInt(request.QueryString("EventID"))
            ' make a unique "filename" for this event
            ' so it can be cached without trouble

            Dim Filename As String = EventID.ToString() & "event.ics"
            response.BufferOutput = True
            response.ContentType = "text/calendar"
            response.AppendHeader("Filename", Filename)
            response.AppendHeader("Content-Disposition", "attachment;filename=" & Filename)
            ' allow it to be cached so IE can save it where Outlook will find it
            response.Cache.SetCacheability(HttpCacheability.Public)
            Dim viewurl As New Uri(context.Request.Url, "Events_view.aspx?Eventid=" & EventID)
            writeCalEntry(eventid, response.Output, viewurl.ToString)
            response.End()
        End Sub

    That fixes the original problem except for one thing, the add event code will allow you to create an event that has an end time that comes before the start time. So when you make an event for tomorrow, unless you are paying attention, that event will end today, and Outlook doesn't like that at all, so we have to fix that code as well...

    In DurationPicker.ascx, change the Property endDateTime() so it looks like this:

        Public Property endDateTime() As Date
            Get
                Dim foo As Date = dp2.SelectedDate.Add(tp2.SelectedTime.TimeOfDay)
                ' make sure we are at least equal to startDateTime, and not before it
                If foo < startDateTime() Then
                    Return startDateTime
                End If
                Return foo
            End Get
            Set(ByVal value As Date)
                dp2.SelectedDate = value
                tp2.SelectedTime = value
            End Set
        End Property

    Now you can't make an event that defies Einstein (Newton is a different story, for an anti-gravity control see... oh never mind).

    If you already have some events posted that have end times that occur before the start time, well, you should maybe edit them so they will open properly in Outlook.

    Let me know if this handles it for you!

    -----

    Note: there is one case where an event ends before it begins, when you fly from Sydney to San Francisco, because of the dateline, you arrive half an hour before you left :)

    186,000 miles per second - it's the Law.

     

    Thanks MrLunch your fix does indeed work.

    Thursday, May 4, 2006 11:16 AM
  • User706866991 posted

    Lex,

     

    I am getting the saem error you psoted a few back, but only randomly.  8 of the events give me the error but the rest work fine.  How did you correct it?

    Bob

    Friday, July 21, 2006 10:05 PM
  • User380413204 posted

    Hi Bob,

    If i remember well you need to discard or re-edit the old Records.

    To get old "Bug-garbage" out as it were.

    This would perhaps also explain your random probem, old records give bug, new don't.

     

    Best regards,

    Lex

    Saturday, July 22, 2006 3:22 AM
  • User706866991 posted

    Lex,


    Tried tis but no luck.. Old records work, new ones don't.  Actuallt cleared out the bad records from the DB anbd re entered.  Still errors out.

     

    Bob

    Friday, July 28, 2006 2:53 PM
  • User706866991 posted

    Update to issue when trying to download event to calendar.

    Deleted all events and verified DB was empty.  Added new event and get the following error.

    Server Error in '/' Application.

    Index and length must refer to a location within the string.
    Parameter name: length

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    Parameter name: length

    Source Error:

    Line 147:      
    Line 148:        Do While offset < sb.Length
    Line 149:            Dim pos As Integer = sb.ToString(offset - 5, 10).IndexOf("=0D=0A")
    Line 150:            If pos = -1 Then
    Line 151:                'Account for the string at the end of where we want to insert

    Source File: d:\hosting\rhhanson63\Events_Download.ashx    Line: 149

    Stack Trace:

    [ArgumentOutOfRangeException: Index and length must refer to a location within the string.
    Parameter name: length]
       System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +2848599
       System.Text.StringBuilder.ToString(Int32 startIndex, Int32 length) +18
       DownloadEvent.EncodeProperty(String key, String value) in d:\hosting\rhhanson63\Events_Download.ashx:149
       DownloadEvent.writeCalEntry(Int32 EventID, TextWriter output, String url) in d:\hosting\rhhanson63\Events_Download.ashx:130
       DownloadEvent.ProcessRequest(HttpContext context) in d:\hosting\rhhanson63\Events_Download.ashx:31
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42 <!-- [ArgumentOutOfRangeException]: Index and length must refer to a location within the string. Parameter name: length at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at System.Text.StringBuilder.ToString(Int32 startIndex, Int32 length) at DownloadEvent.EncodeProperty(String key, String value) in d:\hosting\rhhanson63\Events_Download.ashx:line 149 at DownloadEvent.writeCalEntry(Int32 EventID, TextWriter output, String url) in d:\hosting\rhhanson63\Events_Download.ashx:line 130 at DownloadEvent.ProcessRequest(HttpContext context) in d:\hosting\rhhanson63\Events_Download.ashx:line 31 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --><!-- This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.-->

    Anyone seen this before?

     

    Bob

     

    Wednesday, August 2, 2006 5:03 PM
  • User1122806025 posted

    I got the file to download, but where do you save the event.ics file to so Outlook will see it?

    Also, is there a way to save the file without the Save As dialog prompt?

    I am using Outlook 2000

    Tuesday, August 8, 2006 9:55 AM
  • User706866991 posted

    I just use the open function and it inserts it into the Outlook calendar.  You can save anywhere and then open, if you would like.

     

    Bob

     

    Tuesday, August 8, 2006 6:58 PM
  • User-2006636666 posted

    Just curious.  I implemented this and now outlook can open it right up.  I did notice however that when it saved the event for me it added 2 hours to the begin and end time.  Like there's a timezone setting somewhere that I'm not aware of....  Any thoughts?

     

    Thanks,

    -Doug

    Thursday, August 17, 2006 11:26 PM
  • User654902800 posted

    (for the purpose of discussion, let's just forget about daylight savings time for the moment)

    iCal event times are in UTC (aka GMT aka universal time) so if you make an event on the website for 6 PM, and the website is running on a server that's set to Eastern Time (which is UTC - 5) then the iCal download will say the event is at 11 PM UTC. You download that event to a computer on the west coast (UTC - 8) and it will show up in the outlook calendar as 3 PM (which is 6PM on the east coast).

    So, you can either get the server admin to make the server machine (& database machine if they're not the same boxes) run in your time zone (which makes sense if all your users are in the same time zone), or you can display a note on the website calendar saying something like 'all times are in EST'. Either way, when you make an event on the calendar remember to enter the time correctly for the time zone the machine is running in.

    Friday, August 18, 2006 10:08 PM
  • User-2006636666 posted

    Great stuff.  Thanks for the info! I really appreciate it. 

    I'll see if I can get timezone on the server changed....

     

    Thanks again,

    -Doug

    Friday, August 18, 2006 10:21 PM
  • User523970105 posted

    (for the purpose of discussion, let's just forget about daylight savings time for the moment)

    iCal event times are in UTC (aka GMT aka universal time) so if you make an event on the website for 6 PM, and the website is running on a server that's set to Eastern Time (which is UTC - 5) then the iCal download will say the event is at 11 PM UTC. You download that event to a computer on the west coast (UTC - 8) and it will show up in the outlook calendar as 3 PM (which is 6PM on the east coast).

    So, you can either get the server admin to make the server machine (& database machine if they're not the same boxes) run in your time zone (which makes sense if all your users are in the same time zone), or you can display a note on the website calendar saying something like 'all times are in EST'. Either way, when you make an event on the calendar remember to enter the time correctly for the time zone the machine is running in.

    Another option, if you can't get the server admin to change the time zone of the server, is to change the code to make it appear that the server is in the desired time zone.  The following is a quick-n-dirty fix to writeCalEntry in Events_Download.ashx.  Note that this fix doesn't take into account daylight savings.  Just add the items in bold, adjusting the "-2" argument to TimeSpan to the correct offset for your combination of server time zone and client time zone.  The "-2" below works for my case, which is a server in the US Pacific time zone and clients all in the US Central time zone.  I'm going to dig some more into the System date/time functions to see if I can come up with a more robust solution (takes into account a server that observes daylight savings time and clients that don't, or vice versa), but this works as an immediate band-aid solution.

            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];

                System.DateTime starttime, endtime;
                System.TimeSpan tzconvert = new System.TimeSpan(0, -2, 0, 0);
                string title, description, location;

                StringBuilder sb = new StringBuilder();
                object o;
               
                starttime = (DateTime)dr["starttime"] + tzconvert;
                if (dr["endtime"] != DBNull.Value)
                {
                    endtime = (DateTime)dr["endtime"] + tzconvert;
                }
                else
                {
                    endtime = starttime;
                }

    Wednesday, September 13, 2006 1:11 AM
  • User1812216987 posted

    Great work!

    I've just noticed that the strings seems to be messed up somehow inside Outlook. The url looks like this:

    URL: http://localhost:2899/humlanweb/Events_view.aspx?Eventid . Here the Eventid=19 (in my case) has been cut off.

    Also in the Location: The Bee=0D.  Here "=0D" has been added to the string.

    Seems like the Encoding part of saving the calendar event has gone wrong but I don't understand why. Any ideas?

     

    allan

    Tuesday, October 31, 2006 5:24 AM
  • User2000013726 posted

    Hi Allan,

    To resolve the EventID URL issue do the following...

    Find the following section of code in Events_Download.ashx

    ...
    sb.AppendLine()
    sb.Append("Event URL: ")
    o = dr("staticURL")
    If Not IsDBNull(o) AndAlso Trim(CStr(o)) <> "" Then
        sb.AppendLine(Trim(CStr(o)))
    Else
        sb.AppendLine(url)
    End If
    ...

    And replace the text "url" above with the following:

        sb.AppendLine(Replace(URL, "=", "=3D"))

    What this is doing is replacing all occurrences of the string "=" with the string "=3D".  If you look up the ASCII hex code for 3D here you will see that this the ASCII code for the equals sign.  Then it needs to be prefixed with an equals sign itself, which is the format for directly embedding ASCII characters inside the DESCRIPTION tag of the iCal formatted text file.

    Wednesday, December 13, 2006 2:34 AM
  • User2000013726 posted

    Hi again,

    Here is my version of the EncodeProperty function from Events_Download.ashx.  This appears to work and was what I came up with to resolve the occasional embedded ASCII codes from showing up in Outlook from an apparently bad parse of the DESCRIPTION tag:

    Function EncodeProperty(ByVal key As String, ByVal value As String) As String

    ' iCal Rules *seem* to be as follows:

    ' (1) LineWidth is set to 70 characters
    ' (2) 71st character has to be an "=" signifying the end of the line
    ' (3) Two "=" cannot reside next to each other
    ' (4) =0D or =0A cannot be split after the = or after the =0 part
    ' (5) It is OK to split =0D=0A after the =0D part

     

    Dim sb As New Text.StringBuilder()

    sb.Append(key)
    value = Replace(value, ";", "\;")
    value = Replace(value, vbCrLf, "=0D=0A")
    sb.Append(value)

     

    Const LineWidth As Integer = 70
    Dim CurrentPos As Integer = LineWidth - 1

     

    Do While CurrentPos < sb.Length

    ' Case: "=0D" or "=0A" is split after the "=" part where two "==" would reside next to each other
    If sb.ToString(CurrentPos, 1) = "=" Then
        sb.Insert(CurrentPos, " =" & vbCrLf)

    ' Case: "=0D" or "=0A" is split after the "=0" part
    ' or the "=3D" is at the split point from earlier fix for "=" in URL
    ElseIf sb.ToString(CurrentPos - 1, 2) = "=0" OrElse sb.ToString(CurrentPos - 1, 2) = "=3" Then
        sb.Insert(CurrentPos - 1, " =" & vbCrLf)

    Else
        sb.Insert(CurrentPos + 1, "=" & vbCrLf)

    End If

     

    CurrentPos += LineWidth + 3 ' 1 for the "=" line terminator and 2 for the vbCrLf = 3 total

    Loop

    Return sb.ToString

    End Function

    -Johnson

    Wednesday, December 13, 2006 5:03 AM
  • User530806938 posted

    Try this - in Events_Download.ashx, after this line in method ProcessRequest()

       response.ContentType =

    "text/calendar"

    add these two

       response.AppendHeader(

    "Filename", "event.ics")
       response.AppendHeader(
    "Content-Disposition", "attachment;filename=event.ics")

    and that should convince IE that it's an ical file and let you download it.

    Cheers,

    Worked perfectly for me.

    Thanks!

    Tuesday, July 24, 2007 6:35 PM