Open HarveyCraft opened 5 months ago
@HarveyCraft Hi, can you give me an example of the email you are sending? The format should look like what I wrote here.
It's for a business and it's for making bookings through the website that get sent to gmail into google calendar entries automatically.
The email looks something like this in the subject line. Booking Mail - ID 14411 - (Store: [Business name] ) 19-04-2024 at 08:30 am for example.
And then the email would have the price breakdown for the services offered
and after that the contact info of who booked, our contact info and a breakdown of the services that will be performed.
Also it's not written with CCs or anything like that, it just filters emails from one inbound email address to another email address which worked fine on gmail's end when I made labels.
I just left the time format as ROW because that's how the email formats it and just changed the Gmail Label field GMAILLABEL ' ' with the label I made, ran it and it gave me the errors. I did the gmail filtering just fine idk...
Yeah I think that email subject won't work because it has multiple dashes and my script only accounts for one dash (for adding multi-day events). Didn't plan for edge cases like this.
What if I change it to slashes, is there any way to add a line of code to make an exception for multiple dashes?
You could try slashes, not sure if it will work. Probably could expand this script further to account for multiple dashes. If there were more features do you think you would pay for a service like this?
If there was more features I'd consider it, I haven't seen it work yet if you do make a fix for this let me know and I'll try it out.
Not sure if I'm understanding correctly, but changed the multi day delimiter to "|" using chatGPT, possibly this may help. :
function calcDateTime(rawDate, rawTime, isAllDay) {
// Splitting the rawDate by pipe character to handle multi-day events
var pipeModifierIndex = rawDate.indexOf("|");
var isMultiDay = pipeModifierIndex != -1;
// Get time if event is not an all-day event
if (!isAllDay && !isMultiDay) {
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, pipeModifierIndex);
var endDate = rawDate.substring(pipeModifierIndex + 1);
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];
}
Thanks for suggesting this change @bonelifer !
Needs tested, as I'm not a programmer, even in my dreams in my living room. :)
Makes two of us!
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....