Show Yes No May be options in ICS file using Python
shohagcsediu opened this issue · comments
How to add Yes No May be options in ICS file using Python? please let me know if anyone implemented it.
Hi shohagcsediu, will this snippet do?
import datetime
from datetime import datetime
from icalendar import Calendar, Event, vText, vCalAddress
calendar = Calendar()
calendar.add('prodid', 'icalendar')
calendar.add('version', '2.0')
attende_that_accepted = vCalAddress(f'mailto:someone@example.com')
attende_that_accepted.params['PARSTAT'] = vText('ACCEPTED')
attende_that_declined = vCalAddress(f'mailto:someone1@example.com')
attende_that_declined.params['PARSTAT'] = vText('DECLINED')
tentative_attende = vCalAddress(f'mailto:mum@example.com')
tentative_attende.params['PARSTAT'] = vText('TENTATIVE')
event = Event()
event.add('DTSTART', datetime(2022, 7, 22, 12, 30))
event.add('DTEND', datetime(2022, 7, 22, 16, 30))
event.add('DTSTAMP', datetime.now())
event.add('UID', 'unique-id')
event.add('description', 'Birthday party')
event.add('attendee', attende_that_accepted)
event.add('attendee', attende_that_declined)
event.add('attendee', tentative_attende)
calendar.add_component(event)
print(calendar.to_ical().decode('utf-8'))
The output:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar
BEGIN:VEVENT
DTSTART:20220722T123000
DTEND:20220722T163000
DTSTAMP:20230118T225027Z
UID:unique-id
ATTENDEE;PARSTAT=ACCEPTED:mailto:someone@example.com
ATTENDEE;PARSTAT=DECLINED:mailto:someone1@example.com
ATTENDEE;PARSTAT=TENTATIVE:mailto:mum@example.com
DESCRIPTION:Birthday party
END:VEVENT
END:VCALENDAR
If that is it, it can be put into the documentation.