You need to sign in to do that
Don't have an account?
tengel
Output datetime in UTC format for VF email template
I have a custom object that has Start and End fields as datetime. I am trying to create a Visualforce email template that will be able to send an email with a .ics attachment that will use my object's Start/End fields.
I've got everything working except that my object's field values are getting output as GMT, not UTC, and the .ics format needs UTC. Here's what I've got in the template (PS, I've tried not wrapping my fields in the outputText tags, the result is the same):
I've got everything working except that my object's field values are getting output as GMT, not UTC, and the .ics format needs UTC. Here's what I've got in the template (PS, I've tried not wrapping my fields in the outputText tags, the result is the same):
DTSTART;TZID="Eastern Standard Time":<apex:outputText value="{!RelatedTo.evt__Event__r.evt__Start__c}" /> DTEND;TZID="Eastern Standard Time":<apex:outputText value="{!RelatedTo.evt__Event__r.evt__End__c}" />Here is an example of what gets output in the resulting .ics file:
DTSTART;TZID="Eastern Standard Time":Mon Jul 06 17:00:00 GMT 2015 DTEND;TZID="Eastern Standard Time":Mon Jul 06 21:00:00 GMT 2015How do I just get VF to output my fields in UTC? Isn't this how they are actually stored in the database, anyway??
Note that we specify the timezone to be GMT (that tells the client program that reads the date that the value is specified in GMT and that the client program should adjust it appropriately for the locale of the end-user) then the outputText value uses a series of SUBSTITUTE commands to strip unecessary characters out.
In this example, $CurrentPage.parameters.start could be replaced by the formula {!TEXT(yourObject.yourDateTimeField)}
My test emails deliver just fine to services like Gmail. I receive the calendar request, can accept it, beautiful!
However, when the message is opened in an MS Outlook client (Outlook 2010, in this case), the message is delivered properly with the .ics attachment BUT the attachment is labeled "not supported calendar message.ics" (even though I've specified the filename as "meeting.ics"). Yet, when I open the attachment, it opens the MS Calendar to the correct date & time as specified in my Salesforce object fields. I did some googling, but the only consistent solution I see that addresses this has something to do with Lotus Notes recurring meetings, which doesn't apply in this case. Any chance my code below tips you off to anything???
This is the code in my VF template:
This is how that code renders when delivered: