I am trying to build a button to be included in an email that goes to a public page to generate an ICS file. We also have in the email a visualforce attachment but this does not work with mobile outlook(attachment is just completely not there) and ios, therefore the button is a fail safe for the client to click. The below only works with desktop outlook and doesn't work with any mobile app.
The main difference between the visualforce page and the message:attachment in the email is that I can't get breaklines to work and suspect this is what is causing the visualforce page generated ics to not work on mobile. I have tried every forum thread suggestions of using different things like \n,
etc for line breaks but when you download the file it will just display the entire file in one line (and include '\n' or '
).
Page:
<apex:page standardController="Event" ContentType="text/calendar">
BEGIN:VCALENDAR
PRODID:-//GourmetPortal//NONSGML rr//DE
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(Event.StartDateTime),':',''),'-',''),' ','T')}"/>
DTEND;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(Event.EndDateTime),':',''),'-',''),' ','T')}"/>
DTSTAMP;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/>
ORGANIZER;CN=test@futureassist.com.au:mailto:test@futureassist.com.au
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;X-NUM-GUESTS=0:mailto:<apex:outputtext value="{!Event.Client_Email__c}"/>
UID:<apex:outputText value="{!Event.id}"/>
CREATED;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/>
DESCRIPTION:<apex:outputText value="Please contact your adviser if you need to reschedule the time of this appointment" escape="false"/>
LAST-MODIFIED;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/>
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:<apex:outputText value="{!Event.Subject}"/>
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:This is an event reminder
TRIGGER:-P0DT0H30M0S
END:VALARM
END:VEVENT
END:VCALENDAR
</apex:page>
Extension:
public with sharing class GenerateEventICS {
public String getLocation() {
return location;
}
public String getSummary() {
return summary;
}
public String getEndDate() {
return endDate;
}
public String getStartDate() {
return startDate;
}
private final String startDate;
private final String endDate;
private final String summary;
private final String location;
public GenerateEventICS(ApexPages.StandardController controller){
ApexPages.currentPage().getHeaders().put('content-disposition','inline; filename=calendarEvent.ics');
startDate = ApexPages.currentPage().getParameters().get('startDate');
endDate = ApexPages.currentPage().getParameters().get('endDate');
summary = ApexPages.currentPage().getParameters().get('summary');
location = ApexPages.currentPage().getParameters().get('location');
}
}
Message attachment for reference (it's the same things but break line works):
<messaging:attachment filename="{!relatedTo.Subject}.ics" renderAs="text/calendar">
BEGIN:VCALENDAR
PRODID:-//GourmetPortal//NONSGML rr//DE
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.StartDateTime),':',''),'-',''),' ','T')}"/>
DTEND;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.EndDateTime),':',''),'-',''),' ','T')}"/>
DTSTAMP;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/>
ORGANIZER;CN=test@futureassist.com.au:mailto:test@futureassist.com.au
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;X-NUM-GUESTS=0:mailto:<apex:outputtext value="{!relatedto.Client_Email__c}"/>
UID:<apex:outputText value="{!relatedTo.id}"/>
CREATED;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/>
DESCRIPTION:<apex:outputText value="Please contact your adviser if you need to reschedule the time of this appointment" escape="false"/>
LAST-MODIFIED;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/>
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:<apex:outputText value="{!relatedTo.Subject}"/>
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:This is an event reminder
TRIGGER:-P0DT0H30M0S
END:VALARM
END:VEVENT
END:VCALENDAR
</messaging:attachment>
Opening the visualforce page generated ics in notepad:
Opening the message:attachment generated ics in notepad:
<br/>
at the end of each line, see if it works – Novarg Sep 13 '17 at 9:30\r\n
? – Novarg Sep 13 '17 at 12:49