-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathmeetingRequest.js
145 lines (112 loc) · 3.54 KB
/
meetingRequest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var icalToolkit = require('ical-toolkit')
var sendmail = require('../sendmail')({silent: true})
// Create a builder
var builder = icalToolkit.createIcsFileBuilder()
/*
* Settings (All Default values shown below. It is optional to specify)
* */
builder.spacers = true // Add space in ICS file, better human reading. Default: true
builder.NEWLINE_CHAR = '\r\n' // Newline char to use.
builder.throwError = false // If true throws errors, else returns error when you do .toString() to generate the file contents.
builder.ignoreTZIDMismatch = true // If TZID is invalid, ignore or not to ignore!
/**
* Build ICS
* */
// Name of calander 'X-WR-CALNAME' tag.
builder.calname = 'Yo Cal'
// Cal timezone 'X-WR-TIMEZONE' tag. Optional. We recommend it to be same as tzid.
builder.timezone = 'america/new_york'
// Time Zone ID. This will automatically add VTIMEZONE info.
builder.tzid = 'america/new_york'
// Method
builder.method = 'REQUEST'
// Add events
builder.events.push({
// Event start time, Required: type Date()
start: new Date(),
// Event end time, Required: type Date()
end: new Date(),
// transp. Will add TRANSP:OPAQUE to block calendar.
transp: 'OPAQUE',
// Event summary, Required: type String
summary: 'Test Event',
// All Optionals Below
// Alarms, array in minutes
alarms: [15, 10, 5],
// Optional: If you need to add some of your own tags
additionalTags: {
'SOMETAG': 'SOME VALUE'
},
// Event identifier, Optional, default auto generated
uid: null,
// Optional, The sequence number in update, Default: 0
sequence: null,
// Optional if repeating event
repeating: {
freq: 'DAILY',
count: 10,
interval: 10,
until: new Date()
},
// Optional if all day event
allDay: true,
// Creation timestamp, Optional.
stamp: new Date(),
// Optional, floating time.
floating: false,
// Location of event, optional.
location: 'Home',
// Optional description of event.
description: 'Testing it!',
// Optional Organizer info
organizer: {
name: 'Jason Humphrey',
email: 'jason@yourdomain.com',
sentBy: 'person_acting_on_behalf_of_organizer@email.com' // OPTIONAL email address of the person who is acting on behalf of organizer.
},
// Optional attendees info
attendees: [
{
name: 'A1', // Required
email: 'a1@email.com', // Required
status: 'TENTATIVE', // Optional
role: 'REQ-PARTICIPANT', // Optional
rsvp: true // Optional, adds 'RSVP=TRUE' , tells the application that organiser needs a RSVP response.
},
{
name: 'A2',
email: 'a2@email.com'
}
],
// What to do on addition
method: 'PUBLISH',
// Status of event
status: 'CONFIRMED',
// Url for event on core application, Optional.
url: 'http://google.com'
})
// Optional tags on VCALENDAR level if you intent to add. Optional field
builder.additionalTags = {
'SOMETAG': 'SOME VALUE'
}
// Try to build
var icsFileContent = builder.toString()
// Check if there was an error (Only required if yu configured to return error, else error will be thrown.)
if (icsFileContent instanceof Error) {
console.log('Returned Error, you can also configure to throw errors!')
// handle error
}
sendmail({
from: 'test@yourdomain.com',
to: 'info@yourdomain.com',
replyTo: 'jason@yourdomain.com',
subject: 'MailComposer sendmail',
html: 'Mail of test sendmail ',
alternatives: [{
contentType: 'text/calendar; charset="utf-8"; method=REQUEST',
content: icsFileContent.toString()
}]
}, function (err, reply) {
console.log(err && err.stack)
console.dir(reply)
})