Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Yes No May be options in ICS file using Python #510

Closed
Tracked by #443
shohagcsediu opened this issue Jan 17, 2023 · 2 comments
Closed
Tracked by #443

Show Yes No May be options in ICS file using Python #510

shohagcsediu opened this issue Jan 17, 2023 · 2 comments

Comments

@shohagcsediu
Copy link

How to add Yes No May be options in ICS file using Python? please let me know if anyone implemented it.

@jacadzaca
Copy link
Collaborator

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

@niccokunzmann
Copy link
Member

niccokunzmann commented Jan 19, 2023 via email

@collective collective locked and limited conversation to collaborators Aug 30, 2023
@niccokunzmann niccokunzmann converted this issue into discussion #540 Aug 30, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants