al-codaio / events-from-gmail Goto Github PK
View Code? Open in Web Editor NEWCreate Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script.
Create Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script.
I've got the email set to a multi-line body, however it only grabs the first line. I would like to dump the entirety of the message body into the description for the event, but I'm unclear on how to make this happen. I've included a copy of the body below for reference. Any help would be greatly appreciated.
Name: Test Test
Email: [email protected]
Date/time: 21/11/2022 12:00
Phone: -
Suggested location: -
Notes: -
I haven't touched coding since now but I followed this tutorial on how to scrape emails from gmail and make them calendar events to a tee and it spat out this error message, idk what to do
Error
TypeError: Cannot read properties of undefined (reading 'indexOf')
calcDateTime @ Code.gs:88
parseEmail @ Code.gs:38
getEmail @ Code.gs:23
EDIT: I'm pretty sure it's having trouble figuring out stuff with the date but that's the extent of my guessing....
It would be nice to have multi-line descriptions. I often create doctors appointments with the Address +number, due to the fact I have to use a free disability transport and I need that info on hand when I make a pickup appointment with them. I can only make these pickup appointments 12 days in advanced(some of my appointments are more than a month out), so it would be nice to still have all that info in the description as I have been doing it manually.
It would be convenient to be able to add the event to a specific calendar instead of the default one.
Problem:
It seems to break when the parseDate(rawDate) function is called, the date gets passed down wrong. I have also switched it to US format to see if that would fix it and still no dice. I believe it's breaking right before that. Newish to this language and hitting wall, would appreciate your help. :)
Notes:
Subject line looks like this:
Patch Series, 23-4, 5 PM
I can't change the subject format from a - to a /
I replaced the var dateDetails = date.split("/") with var dateDetails = date.split("-")
Added some console.log trying to debug what's going on but running into date getting passed as just the day and not the dd-mm that we're looking for.
Execution log:
3:45:25 PM Notice Execution started
3:45:26 PM Info 23-4
3:45:26 PM Info 23
3:45:25 PM Error
TypeError: Cannot read property 'trim' of undefined
parseDate @ Code.gs:121
calcDateTime @ Code.gs:96
parseEmail @ Code.gs:38
getEmail @ Code.gs:23
calcDateTime(rawDate, rawTime, isAllDay) {
var dashModifierIndex = rawDate.indexOf("-")
var isMultiDay = dashModifierIndex == -1 ? false : true
console.log(rawDate)
// Get time if event is not an all-day event
if (isAllDay == false && isMultiDay == false) {
var [month, day, year] = parseDate(rawDate)
var [hours, minutes] = convertTime12to24(rawTime)
var newDateStart = new Date(year, month - 1, day, hours, minutes)
var newDateEnd = new Date(newDateStart)
newDateEnd.setMinutes(newDateStart.getMinutes() + DEFAULT_EVENT_TIME)
} else {
// Set start and end date if event is multi-day
if (isMultiDay) {
var startDate = rawDate.substring(0, dashModifierIndex)
var endDate = rawDate.substring(dashModifierIndex + 1, rawDate.length)
var [startMonth, startDay, startYear] = parseDate(startDate)
var [endMonth, endDay, endYear] = parseDate(endDate)
var newDateStart = new Date(startYear, startMonth - 1, startDay)
var newDateEnd = new Date(endYear, endMonth - 1, endDay)
isAllDay = true
} else {
var [month, day, year] = parseDate(rawDate)
var newDateStart = newDateEnd = new Date(year, month - 1, day)
}
}
return [newDateStart, newDateEnd, isAllDay]
}
// Get month, day, year from date with slash
function parseDate(date) {
console.log(date)
var dateDetails = date.split("-")
I have to add for the date the correct year (2022). if i write just "22" it will be 1922
if i write just: 1/4 (date format: ROW) the date created will be first of april 2021
any ideas?
my system:
OS: Linux
Browser: Chrome
HI,
i have a issue with the script. I hope i did everything right. But still i got the error messages:
I got the wrong timezone
i am in timezone GTM+2
Event created was GTM-5
my system:
OS: Linux
Browser: Chrome
Timezone: gtm +2, Checked in OS and Google calendar
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.