﻿// JScript File

var formattedDate;
var olAppointmentItem = 1; //fixed for different properties of outlook object

//EXPORT to OUTLOOK
function ExportDataToOutlook(sBody)
{
    var duration = 120; //number of minutes (duration in Outlook being in minutes)
    SetTimeForAppointment();//time of appoinment was fixed 
    try
    {
        var objOutlook = new ActiveXObject( "Outlook.Application" );
    }
    catch(e)
    {
        alert("Outlook needs to be installed on the machine for data to export.");
        return false;
    }
    var objAppointment = objOutlook.CreateItem(olAppointmentItem);
    
    objAppointment.Subject = "Schedule For Scorecrazy.com";                                                               
    objAppointment.Body = sBody;
    //C:\inetpub\vhosts\wafatechnology.com\\httpdocs\\scorecrazy\\
   // objAppointment.Attachements.Add ("C:\inetpub\vhosts\wafatechnology.com\\httpdocs\\scorecrazy\\UploadedSchedule\\schdules.txt");
    objAppointment.Start = formattedDate; 
    objAppointment.Duration = duration; 
    objAppointment.ReminderSet = false;                               
    objAppointment.Save(); 
    
    alert("This schdule Has been attached successfully to your Outlook calendar in todays date.");
    return true;
}

function SetTimeForAppointment()
{
    var currentDate = new Date();
    var month = currentDate.getMonth();
    var day = currentDate.getDate();
    var year = currentDate.getFullYear();
    formattedDate = (month+1) + "/" + day + "/" + year + " 08:00AM"; 
}