This repository was archived by the owner on Mar 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
89 lines (81 loc) · 2.15 KB
/
index.js
File metadata and controls
89 lines (81 loc) · 2.15 KB
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
import nodemailer from "nodemailer";
import { writeFileSync } from "fs";
import ics from "ics";
// for the ics file
const eventtitle = 'Vacation';
const eventdescription = '';
const eventstatus = 'BUSY';
const eventlocation = 'Germany';
const eventmethod = 'request';
const eventattendees = { name: 'Max Mustermann', email: 'max@germany.de', rsvp: true, partstat: 'ACCEPTED', role: 'REQ-PARTICIPANT' };
const eventorganizer = { name: 'Max Mustermann', email: 'max@germany.de' };
// year, month, day
const starttime = [2023, 3, 15];
const durationtime = { days: 1 };
// for sending mail
const frommail = 'germany@germany.de';
const tomail = 'max@germany.de; max2@germany.de';
const mailsubject = 'Max Mustermann ICS File';
const hostserver = 'webmail.germanyde';
const hostport = '587';
// authentication
const userdomain = 'd';
const loginname = 'maxm';
const loginpasswort = 'xxxyyyzzz';
// transport of the mail (OWA [Office 365])
var o365Transport = nodemailer.createTransport({
host: hostserver,
secure: false,
port: hostport,
tls: {
ciphers: "SSLv3",
rejectUnauthorized: false,
},
auth: {
domain: userdomain,
user: loginname,
pass: loginpasswort,
},
debug: true,
logger:true,
});
// generate ics file
ics.createEvent({
title: eventtitle,
description: eventdescription,
busyStatus: eventstatus,
location: eventlocation,
method: eventmethod,
start: starttime,
duration: durationtime,
organizer: eventorganizer,
attendees: [eventattendees]
}, (error, value) => {
if (error) {
console.log(error)
}
writeFileSync(`event.ics`, value)
})
// build the mail and send it
async function sendemail() {
let message = {
from: frommail,
to: tomail,
subject: mailsubject,
text: '',
icalEvent: {
filename: 'event.ics',
method: eventmethod,
path: 'event.ics',
encoding: 'base64'
}
}
o365Transport.sendMail(message, function (error, response) {
if (error) {
console.log(error);
} else {
console.log("Message sent: " , response);
}
})
}
sendemail();