Announcement

Collapse
No announcement yet.

Create agenda event in Outlook, how to...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create agenda event in Outlook, how to...

    I want to create with a sc-button an event in an outlook agenda.

    I have the variables:

    $begin_date
    $end_date
    $start_time
    $end_time
    $email_adres // to point out in which email-account the event should come.
    $subject
    $location

    Can this been done with a PHP-script in a sc_button?

    Would be very nice if somebody can help

    Regards, Bert

  • #2
    When you say outlook agenda you mean exactly Microsoft outlook?
    If it is for client side you can construct an offer to download an ics file
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Hi Giu,

      Yes I mean Microsoft Outlook.
      Yes it is for clientside.

      How does the php script look?

      Regards, Bert

      Comment


      • #4
        There are a lot of options, I didn't used any of them sorry, but a fast search between different options you have this:
        https://gist.github.com/jakebellacera/635416

        Copy/paste on blank app for example and adjust at your needs.
        /Giuseppe

        Professional Scriptcase Services
        Some Customers opinions

        Comment


        • #5
          I will give it a try, thanks.
          Between the <?php ....?> I understand
          But beginning with:
          BEGIN:VCALENDAR
          etc

          Where to put that?

          Comment


          • #6
            Originally posted by ctmservice View Post
            I will give it a try, thanks.
            Between the <?php ....?> I understand
            But beginning with:
            BEGIN:VCALENDAR
            etc

            Where to put that?
            header('Content-Disposition: attachment; filename=' . $filename);

            This is to change the output of the file and deliver as a download. probably if $filename is meeting.ics this will be the name of the file downloadable
            Code:
            BEGIN:VCALENDAR
            VERSION:2.0
            PRODID:-//hacksw/handcal//NONSGML v1.0//EN
            CALSCALE:GREGORIAN
            BEGIN:VEVENT
            DTEND:<?= dateToCal($dateend) ?>
            UID:<?= uniqid() ?>
            DTSTAMP:<?= dateToCal(time()) ?>
            LOCATION:<?= escapeString($address) ?>
            DESCRIPTION:<?= escapeString($description) ?>
            URL;VALUE=URI:<?= escapeString($uri) ?>
            SUMMARY:<?= escapeString($summary) ?>
            DTSTART:<?= dateToCal($datestart) ?>
            END:VEVENT
            END:VCALENDAR
            This is the output the ICS file should have, as you can see is filled automatically with variables.

            Try to paste as this on a Blank app:

            Code:
            header('Content-type: text/calendar; charset=utf-8');
            header('Content-Disposition: attachment; filename=' . $filename);
            
            // 2. Define helper functions
            
            // Converts a unix timestamp to an ics-friendly format
            // NOTE: "Z" means that this timestamp is a UTC timestamp. If you need
            // to set a locale, remove the "\Z" and modify DTEND, DTSTAMP and DTSTART
            // with TZID properties (see RFC 5545 section 3.3.5 for info)
            //
            // Also note that we are using "H" instead of "g" because iCalendar's Time format
            // requires 24-hour time (see RFC 5545 section 3.3.12 for info).
            function dateToCal($timestamp) {
              return date('Ymd\THis\Z', $timestamp);
            }
            
            // Escapes a string of characters
            function escapeString($string) {
              return preg_replace('/([\,;])/','\\\$1', $string);
            }
            
            // 3. Echo out the ics file's contents
            ?>
            BEGIN:VCALENDAR
            VERSION:2.0
            PRODID:-//hacksw/handcal//NONSGML v1.0//EN
            CALSCALE:GREGORIAN
            BEGIN:VEVENT
            DTEND:<?= dateToCal($dateend) ?>
            UID:<?= uniqid() ?>
            DTSTAMP:<?= dateToCal(time()) ?>
            LOCATION:<?= escapeString($address) ?>
            DESCRIPTION:<?= escapeString($description) ?>
            URL;VALUE=URI:<?= escapeString($uri) ?>
            SUMMARY:<?= escapeString($summary) ?>
            DTSTART:<?= dateToCal($datestart) ?>
            END:VEVENT
            END:VCALENDAR
            Now, for example, change $ variables of the ICS block with SC global vars, and fill it when calling the app.

            I think should work.
            /Giuseppe

            Professional Scriptcase Services
            Some Customers opinions

            Comment

            Working...
            X