You need to sign in to do that
Don't have an account?
tengel
Unwanted Line Break in Visualforce Email Template Attachment
I have a VF email template that should get delivered with a .ical attachment. When the email gets delivered, the .ical's first line appears to be a line break. This prevents it from validating correctly at this validator (http://severinghaus.org/projects/icv/), and it also causes issues when trying to open with Outlook, for example. When I edit the attachment and remove the first line break, it validates and opens fine in Outlook.
I don't see where in the VF itself the line break is getting introduced. Can anyone offer some help? For context, when the rendered file gets delivered via email, there is a blank line right before "BEGIN:VCALENDAR" which is causing the issue.
I don't see where in the VF itself the line break is getting introduced. Can anyone offer some help? For context, when the rendered file gets delivered via email, there is a blank line right before "BEGIN:VCALENDAR" which is causing the issue.
</body> </messaging:htmlEmailBody> <messaging:attachment filename="{!RelatedTo.evt__Event__r.Name}.ics" renderAs="text/calendar; charset=UTF-8; method=PUBLISH"> BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN VERSION:2.0 METHOD:PUBLISH X-WR-TIMEZONE:America/New_York BEGIN:VEVENT DTSTAMP:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ','T')}"/> UID:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(RelatedTo.evt__Event__r.evt__Start__c),':',''),'-',''),' ','T')}"/> ATTENDEE;CN={!RelatedTo.evt__Email__c} STATUS:CONFIRMED DTSTART;TZID=America/New_York:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(RelatedTo.evt__Event__r.evt__Start__c),':',''),'-',''),' ','T')}"/> DTEND;TZID=America/New_York:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(RelatedTo.evt__Event__r.evt__End__c),':',''),'-',''),' ','T')}"/> LOCATION:{!RelatedTo.evt__Event__r.evt__Venue_Name__c} - {!RelatedTo.evt__Event__r.evt__Street__c}, {!RelatedTo.evt__Event__r.evt__City__c} {!RelatedTo.evt__Event__r.evt__State__c} {!RelatedTo.evt__Event__r.evt__Postal_Code__c} ORGANIZER;CN="Lawley Insurance":mailto:lawley@lawleyinsurance.com PRIORITY:5 SEQUENCE:0 SUMMARY;LANGUAGE=en-us:{!RelatedTo.evt__Event__r.Name} TRANSP:OPAQUE END:VEVENT END:VCALENDAR </messaging:attachment> </messaging:emailTemplate>
Shashank (Salesforce Developers)
Please see if this sample code helps: https://gist.github.com/DouglasCAyers/247f895a1e4324505c65