PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Attaching an ics (event) file with text/Calendar mime type - help?

  1. Hi,

    I'm tying to attach a .ics file to an admin notification email. I can do this fine in that when the email arrives it has the file attached. However it doesn't behave the same way that an invitation from GCal/Outlook/iCal would, i.e. letting you add the invitation/appointment to your calendar directly from the mail client.

    It looks like the reason is down to the 'Content-Type' in the email. When I send one from GCal/Outlook/iCal that works fine, this is what I see in the bottom of the email source:

    --[mesage id here]
    Content-Type: text/calendar; charset="utf-8"; method=REQUEST
    Content-Transfer-Encoding: base64
    
    [encoded string here]

    When I attach a file with this code:

    add_filter("gform_admin_notification_attachments_4", "add_attachment", 10, 3);
    function add_attachment($attachments, $lead, $form){
    	$doc = '/invite.ics';
    	$upload = wp_upload_dir();
        $upload_path = $upload["basedir"];
        $attachments = array();
        $attachments[] = $upload_path . $doc;
        return $attachments;
    }

    I get this in the email:

    --[mesage id here]
    Content-Type: application/octet-stream; name="invite.ics"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename="invite.ics"
    
    [encoded string here]

    Any ideas how I can enforce the correct content type so the mail clients know how to handle it?

    Thanks,
    Ben

    Posted 12 years ago on Wednesday December 19, 2012 | Permalink
  2. The only option for email notification format in Gravity Forms is HTML or text which can be controlled by the gform_notification_format.

    http://www.gravityhelp.com/documentation/page/Gform_notification_format

    To have complete control over the email notification format, you might have to craft your own notification with the proper Content-type, using phpmailer. Here is how one person did it:

    http://www.gravityhelp.com/forums/topic/send-from-field-on-notification-setting-page-doesnt-work#post-77233

    You could turn off the default admin notification, and use the gform_after_submission hook to send your own notification.

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    Posted 12 years ago on Thursday December 20, 2012 | Permalink