• tolian02
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

I am trying to use the new email attachment methods in the winter '10 release to get emails sent from the appointment controller to be sent in an intuitively obvious way such that they will appear as calendar invitations when opened in Outlook, on a blackberry, in gmail, etc.

In the Winter '10: Platform Release Preview Webinar, Sarah Franklin said the following about new email features, "[If] you wanted to send emails that have a calendar attachment in them and have the person receiving the email open that up an go right into their outlook or something… Right now with Winter '10 we are announcing support for that."

If anyone knows how the Force folks were able to achieve this functionality with the new features please let me know.

Here is what I tried:

         Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setSubject(subjectLine);
        email.setToAddresses(toAddresses);
        email.setHtmlBody(AppointmentUtils.getNotificationBody(item.id));
        email.setPlainTextBody(AppointmentUtils.getNotificationBodyText(item.id));
            
        // Create an email attachment   
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName('Appointment.pdf'); // set name of PDF
        efa.setBody(AppointmentUtils.getNotificationPDF(item.id)); //attach the PDF
       

        Messaging.EmailFileAttachment vcal = new Messaging.EmailFileAttachment();
        vcal.setFileName('Appointment.ics');
        vcal.setBody(AppointmentUtils.getNotificationVCal(item.id));
        vcal.setContentType(mime);
            

        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa, vcal});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  


Note this line: vcal.setContentType(mime);

I tried the following values for mime:

text/x-vCalendar

application/x-vCalendar

text/calendar

application/calendar

 

In all of these cases the calendar object showed up as an attachement rather than having the email itself be a calendar invitation.

I am trying to use the new email attachment methods in the winter '10 release to get emails sent from the appointment controller to be sent in an intuitively obvious way such that they will appear as calendar invitations when opened in Outlook, on a blackberry, in gmail, etc.

In the Winter '10: Platform Release Preview Webinar, Sarah Franklin said the following about new email features, "[If] you wanted to send emails that have a calendar attachment in them and have the person receiving the email open that up an go right into their outlook or something… Right now with Winter '10 we are announcing support for that."

If anyone knows how the Force folks were able to achieve this functionality with the new features please let me know.

Here is what I tried:

         Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
        email.setSubject(subjectLine);
        email.setToAddresses(toAddresses);
        email.setHtmlBody(AppointmentUtils.getNotificationBody(item.id));
        email.setPlainTextBody(AppointmentUtils.getNotificationBodyText(item.id));
            
        // Create an email attachment   
        Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName('Appointment.pdf'); // set name of PDF
        efa.setBody(AppointmentUtils.getNotificationPDF(item.id)); //attach the PDF
       

        Messaging.EmailFileAttachment vcal = new Messaging.EmailFileAttachment();
        vcal.setFileName('Appointment.ics');
        vcal.setBody(AppointmentUtils.getNotificationVCal(item.id));
        vcal.setContentType(mime);
            

        email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa, vcal});
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});  


Note this line: vcal.setContentType(mime);

I tried the following values for mime:

text/x-vCalendar

application/x-vCalendar

text/calendar

application/calendar

 

In all of these cases the calendar object showed up as an attachement rather than having the email itself be a calendar invitation.

We're trying to send out ICS attachments for calendar requests, but we can't seem to get this new feature to work correctly.

 

Are there any examples in apex to use these changes?

Are there any special configuration changes necessary?

 

Does anyone know how to use setContentType and setInline methods on EmailFileAttachment? There is no documentation on code usage in the Winter 10 Release notes.

 

I'm trying to send an iCal invite from Apex. I would think the MIME content type would be text/Calendar but I'm not sure how to set that.

 

Thanks,
Rich 

  • October 03, 2009
  • Like
  • 0