Outlook कैलेंडर आइटम्स का प्रबंधन
यह MapiCalendar Aspose.Email लाइब्रेरी में क्लास विभिन्न मेथड्स और एट्रीब्यूट्स प्रदान करती है जो कैलेंडर आइटम्स को कॉन्फ़िगर और मैनिप्युलेट करने में मदद करती हैं। यह Outlook कैलेंडर आइटम्स के प्रभावी प्रबंधन की सुविधा देता है, जो उत्पादकता और संगठन को बढ़ाता है। नीचे उन सेक्शन का विवरण दिया गया है जो आपको कैलेंडर आइटम्स के प्रबंधन के विभिन्न पहलुओं से परिचित कराएंगे।
कैलेंडर आइटम बनाना और सेव करना
कैलेंडर आइटम्स को बनाएं और सहेजें
निम्नलिखित कोड स्निपेट यह दर्शाता है कि कैलेंडर आइटम को ICS फ़ॉर्मेट में कैसे बनाया और सहेजा जाए:
- उस पथ को निर्धारित करें जहाँ आपका कैलेंडर फ़ाइल संग्रहीत होगी।
- एक नया इनिशियलाइज़ करके अपॉइंटमेंट बनाएं। MapiCalendar ऑब्जेक्ट जिसमें स्थान, विषय, विवरण, आरंभ और समाप्ति समय जैसी विशिष्ट विवरण होते हैं।
- निर्धारित डायरेक्टरी में बनायी गई अपॉइंटमेंट को एक ICS फ़ाइल के रूप में सहेजें।
import aspose.email as ae
from datetime import datetime
data_dir = "path/to/data/directory/"
# Create the appointment
calendar = ae.mapi.MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
datetime(2012, 4, 1),
datetime(2012, 5, 1))
calendar.save(data_dir + "CalendarItem_out.ics", ae.calendar.AppointmentSaveFormat.ICS)
कैलेंडर आइटम्स को MSG के रूप में सहेजें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर आइटम को MSG के रूप में कैसे सहेजा जाए:
import aspose.email as ae
from datetime import datetime
# Create the appointment
calendar = ae.mapi.MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
datetime(2026, 6, 1, 21, 30, 0),
datetime(2026, 6, 1, 21, 50, 0))
calendar.save(data_dir + "CalendarItem_out.msg", ae.calendar.AppointmentSaveFormat.MSG)
MapiCalendar से ICS रूपांतरण के लिए प्रोडक्ट ID सेट करें
Aspose.Email लाइब्रेरी आपको एक MapiCalendar (कैलेंडर आइटम) को विशिष्ट विकल्पों के साथ एक ICS (iCalendar) फ़ाइल में सहेजने की अनुमति देती है। नीचे दिया गया प्रॉपर्टीज़ यह आपको कैलेंडर आइटम से जुड़े मूल तिथि और समय स्टैम्प को बरकरार रखने और ICS फ़ाइल में प्रोडक्ट आइडेंटिफ़ायर सेट करने की अनुमति देगा, उदाहरण के लिए "Foo Ltd" के रूप में:
- ics_save_options.keep_original_date_time_stamp
- ics_save_options.product_identifier
प्रोडक्ट आइडेंटिफ़ायर एक फ़ील्ड है जो उस सॉफ़्टवेयर या सेवा को पहचानता है जिसने ICS फ़ाइल उत्पन्न किया।
यहां एक कोड उदाहरण दिया गया है जो MapiCalendar को ICS में सहेजते समय प्रोडक्ट ID सेट करने की अनुमति देता है:
import aspose.email as ae
from datetime import datetime
mapi_calendar = ae.mapi.MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
datetime(2024, 4, 1),
datetime(2024, 4, 2))
ics_save_options = ae.mapi.MapiCalendarIcsSaveOptions()
ics_save_options.keep_original_date_time_stamp = True
ics_save_options.product_identifier = "Foo Ltd"
mapi_calendar.save("my.ics", ics_save_options)
एक कैलेंडर आइटम का प्रोडक्ट पहचानकर्ता पढ़ें और सेट करें
iCalendar फ़ाइल उस प्रोडक्ट को रिकॉर्ड करती है जिसने इसे बनाया था PRODID फ़ील्ड। Aspose.Email इस पहचानकर्ता को कैलेंडर आइटम को ICS और MSG के बीच बदलते समय रखता है, जिससे आप आइटम के स्रोत को ट्रेस कर सकते हैं। पहचानकर्ता निम्न प्रॉपर्टीज़ के माध्यम से उपलब्ध है:
product_idका Appointment क्लास - उस प्रोडक्ट का पहचानकर्ता प्राप्त या सेट करता है जिसने अपॉइंटमेंट बनाया।product_idका MapiCalendar क्लास - उस प्रोडक्ट का पहचानकर्ता प्राप्त या सेट करता है जिसने कैलेंडर आइटम बनाया।product_identifierका MapiCalendarMsgSaveOptions और MapiCalendarIcsSaveOptions क्लासेस - कैलेंडर आइटम सहेजे जाने पर लिखे जाने वाले पहचानकर्ता को सेट करता है।
निम्नलिखित कोड नमूना एक ICS फ़ाइल से प्रोडक्ट आईडेंटिफ़ायर पढ़ता है, अपॉइंटमेंट को MSG में बदलता है AppointmentMsgSaveOptions, कैलेंडर आइटम को एक नए पहचानकर्ता के साथ सहेजता है, और फिर एक और पहचानकर्ता को एक ICS फ़ाइल में लिखता है:
import io
import aspose.email as ae
from aspose.pycore import cast
# Read the product identifier from an iCalendar file
appointment = ae.calendar.Appointment.load("meeting.ics")
print("Appointment product ID:", appointment.product_id)
# The identifier is kept when the appointment is converted to MSG
msg_stream = io.BytesIO()
appointment.save(msg_stream, ae.calendar.AppointmentMsgSaveOptions())
msg_stream.seek(0)
msg = ae.mapi.MapiMessage.load(msg_stream)
if msg.supported_type == ae.mapi.MapiItemType.CALENDAR:
calendar = cast(ae.mapi.MapiCalendar, msg.to_mapi_message_item())
print("MapiCalendar product ID:", calendar.product_id)
# Save the calendar item to MSG with a different product identifier
options = ae.mapi.MapiCalendarMsgSaveOptions()
options.product_identifier = "-//Contoso//Calendar 2.0//EN"
calendar.save("meeting_out.msg", options)
# The identifier set on the item is written to the PRODID field of an ICS file
calendar.product_id = "-//Contoso//Calendar 3.0//EN"
calendar.save("meeting_out.ics", ae.mapi.MapiCalendarIcsSaveOptions())
कुल कैलेंडर इवेंट्स की गिनती करें
यह CalendarReader क्लास एक निर्दिष्ट फ़ाइल से कैलेंडर डेटा पढ़ने और विश्लेषण करने की कार्यक्षमता प्रदान करती है। CalendarReader ऑब्जेक्ट को इनिशियलाइज़ करके, आप इवेंट्स की कुल संख्या, कैलेंडर संस्करण, प्रयुक्त मेथड, और क्या कैलेंडर में कई इवेंट्स हैं जैसे महत्वपूर्ण विवरण निकाल सकते हैं। नीचे एक कोड स्निपेट दिया गया है जो दिखाता है कि कैलेंडर डेटा के साथ कैसे इंटरैक्ट करें और अपॉइंटमेंट्स को इवेंट्स की समग्र सूची के रूप में लोड करें:
import aspose.email as ae
reader = ae.calendar.CalendarReader("calendar.ics")
print(f"Calendar contains {reader.count} events")
print(f"The Version of the calendar is {reader.version}")
print(f"The Method of the calendar is {reader.method}")
print(f"Does the calendar contain multiple events? - {reader.is_multi_events}")
appointments = reader.load_as_multiple()
कैलेंडर आइटम्स में डिस्प्ले रिमाइंडर जोड़ें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर आइटम में एक डिस्प्ले रिमाइंडर कैसे जोड़ें:
import aspose.email as ae
from datetime import datetime
# Create the appointment
calendar = ae.mapi.MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
datetime(2026, 6, 1, 21, 30, 0),
datetime(2026, 6, 1, 21, 50, 0))
calendar.reminder_set = True
calendar.reminder_delta = 45 # 45 minutes before the start of the event
calendar.save(data_dir + "AddDisplayReminderToCalendar_out.ics", ae.calendar.AppointmentSaveFormat.ICS)
calendar.save(data_dir + "AddDisplayReminderToCalendar_out.msg", ae.calendar.AppointmentSaveFormat.MSG)
कैलेंडर आइटम्स में ऑडियो रिमाइंडर जोड़ें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर आइटम में एक ऑडियो रिमाइंडर कैसे जोड़ें:
import aspose.email as ae
from datetime import datetime
# Create the appointment
calendar = ae.mapi.MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
datetime(2026, 6, 1, 21, 30, 0),
datetime(2026, 6, 1, 21, 50, 0))
calendar.reminder_set = True
calendar.reminder_delta = 45 # 45 minutes before the start of the event
calendar.reminder_file_parameter = "file://Alarm01.wav"
calendar.save(data_dir + "AddAudioReminderToCalendar_out.ics", ae.calendar.AppointmentSaveFormat.ICS)
MapiCalendar स्थिति को स्पष्ट रूप से सेट करें
Aspose.Email एक विधि प्रदान करता है जिससे आप MapiCalendar ऑब्जेक्ट की स्थिति को स्पष्ट रूप से परिभाषित कर सकते हैं, डिफ़ॉल्ट व्यवहार को ओवरराइड करके:
- void MapiCalendar.set_state_forced(MapiCalendarState state) - प्राप्त मीटिंग रिक्वेस्ट्स के साथ काम करते समय कैलेंडर आइटम की स्थिति पर अधिक नियंत्रण प्रदान करता है।
जब एक MapiCalendar ऑब्जेक्ट बनाया जाता है, तो इसे स्वचालित रूप से स्थिति MapiCalendarState.MEETING दी जाती है। जब आइटम प्राप्तकर्ता द्वारा प्राप्त किया जाता है, तो स्थिति आमतौर पर MapiCalendarState.RECEIVED में बदल जाती है, और संदेश वर्ग "IPM.Schedule.Meeting.Request" में अपडेट हो जाता है।
नीचे दिया गया कोड उदाहरण दिखाता है कि Aspose.Email for Python via .NET का उपयोग करके मीटिंग अपॉइंटमेंट कैसे बनाया जाए, ऑर्गेनाइज़र और कैलेंडर स्थिति को मैन्युअल रूप से सेट किया जाए, और अपॉइंटमेंट को Outlook .msg फ़ाइल के रूप में सहेजा जाए:
from aspose.email.mapi import MapiCalendar, MapiCalendarState, MapiElectronicAddress
from aspose.email.calendar import AppointmentSaveFormat
from datetime import datetime, timezone
# Create a MapiCalendar appointment
appointment = MapiCalendar(
"LAKE ARGYLE WA 6743", # Location
"Appointment", # Subject
"This is a very important meeting :)", # Body
datetime(2024, 5, 10, 12, 30, 0, tzinfo=timezone.utc), # Start time (UTC)
datetime(2024, 5, 10, 13, 30, 0, tzinfo=timezone.utc) # End time (UTC)
)
# Set the organizer
appointment.organizer = MapiElectronicAddress()
appointment.organizer.email_address = "test@aaa.com"
appointment.organizer.display_name = "test display Name"
# Forcefully set the calendar state to Meeting | Received
appointment.set_state_forced(MapiCalendarState.MEETING | MapiCalendarState.RECEIVED)
# Save the appointment to a .msg file
appointment.save("appointment.msg", AppointmentSaveFormat.MSG)
को कॉल करके set_state_forced, आप कैलेंडर आइटम की स्थिति को मैन्युअल रूप से एक विशिष्ट मान (जैसे, MapiCalendarState.RECEIVED) पर सेट कर सकते हैं। यह विशेष रूप से उपयोगी है जब आप चाहें:
-
एक प्राप्त मीटिंग रिक्वेस्ट का सिमुलेशन करें।
-
.MSG फ़ाइल में अपॉइंटमेंट सहेजते समय ऑर्गेनाइज़र और मीटिंग मेटाडाटा संरक्षित रखें।
-
डिफ़ॉल्ट व्यवहार पर्याप्त न होने पर कैलेंडर वर्कफ़्लो को कस्टमाइज़ करें।
नोट: मैन्युअल रूप से स्थिति सेट करना साथ
set_state_forcedOutlook के व्यवहार को प्रभावित कर सकता है, जैसे मीटिंग को फॉरवर्ड या रीसेन्ड करने की क्षमता। इसलिए इसे सावधानी से और केवल तभी उपयोग किया जाना चाहिए जब आपके एप्लिकेशन लॉजिक के लिए आवश्यक हो।
कैलेंडर फ़ाइल प्रबंधन
कैलेंडर फ़ाइलों से अटैचमेंट जोड़ें या प्राप्त करें
Aspose.Email कैलेंडर मॉड्यूल (aspose.email.calendar) भी अटैचमेंट जानकारी जोड़ने और प्राप्त करने की कार्यक्षमता प्रदान करता है।
अपॉइंटमेंट में अटैचमेंट शामिल करने के लिए, नीचे दिए गए चरणों का पालन करें:
- एक बनाएं Attachment फ़ाइल पाथ प्रदान करने वाला ऑब्जेक्ट।
- इस अटैचमेंट को अपॉइंटमेंट की अटैचमेंट सूची में जोड़ें।
- iCalendar फ़ॉर्मेट में एक विशिष्ट फ़ाइल पाथ पर अपॉइंटमेंट सहेजें, उपयोग करके save विधि और उपयुक्त फ़ाइल फ़ॉर्मेट।
एक अपॉइंटमेंट से अटैचमेंट्स प्राप्त करने के लिए, निम्न चरणों का पालन करें:
- सहेजी गई फ़ाइल से अपॉइंटमेंट लोड करें जिससे लोड विधि।
- .attachments.length प्रॉपर्टी का उपयोग करके अपॉइंटमेंट में अटैचमेंट्स की संख्या प्राप्त करें।
- प्रत्येक अटैचमेंट पर इटरेट करें।
- लूप के भीतर .name प्रॉपर्टी का उपयोग करके प्रत्येक अटैचमेंट का नाम प्रिंट करें।
नीचे दिया गया कोड स्निपेट दिखाता है कि अटैचमेंट्स के साथ अपॉइंटमेंट कैसे बनाएं, उन्हें सहेजें, और "ae.calendar" मॉड्यूल का उपयोग करके अटैचमेंट जानकारी प्राप्त करें। यह कैलेंडर एप्लीकेशन में अपॉइंटमेंट्स और अटैचमेंट्स के साथ काम करने की कार्यक्षमता और क्षमताओं को उजागर करता है।
import aspose.email as ae
import datetime as dt
# Add an attachment to an appointment
attendees = ae.MailAddressCollection()
attendees.append(ae.MailAddress("attendee@domain.com", "Recipient 1"))
appointment = ae.calendar.Appointment("Room 112", dt.datetime(2023, 5, 27), dt.date(2023, 5, 28), ae.MailAddress("organizer@domain.com"), attendees)
attachment = ae.Attachment(data_dir + "Attachment.txt")
appointment.attachments.append(attachment)
appointment.save(data_dir + "appWithAttachments_out.ics", ae.calendar.AppointmentSaveFormat.ICS)
# Retrieve attachments from an appointment
appointment2 = ae.calendar.Appointment.load(data_dir + "appWithAttachments_out.ics")
print(len(appointment2.attachments))
for att in appointment2.attachments:
print(att.name)
मीटिंग रिक्वेस्ट्स से प्राप्तकर्ता की स्थिति प्राप्त करें
Aspose.Email आपको मीटिंग रिक्वेस्ट्स के साथ काम करने की अनुमति देता है, जो MapiCalendar ऑब्जेक्ट के रूप में दर्शाए गए होते हैं, और इन मीटिंग रिक्वेस्ट्स से प्राप्तकर्ता की स्थिति (हाजिरी ट्रैकिंग) प्राप्त करने में सहायता करता है। नीचे दिया गया कोड स्निपेट दिखाता है कि प्रत्येक प्राप्तकर्ता के लिए ईमेल की स्थिति कैसे पहचानी जाए:
from aspose.email.mapi import MapiMessage
message = MapiMessage.load(data_dir + "MeetingRequest.msg")
for recipient in message.recipients:
print(f"{recipient.display_name}: {recipient.recipient_track_status}")
HTML बॉडी को संरक्षित रखते हुए EML अपॉइंटमेंट को MSG में बदलें
Aspose.Email EML अपॉइंटमेंट को MSG में बदलने और HTML बॉडी को संरक्षित करने की सुविधा प्रदान करता है। forced_rtf_body_for_appointment प्रॉपर्टी का MapiConversionOptions क्लास अपॉइंटमेंट बॉडी के प्रकार को बदलने के लिए उपयोग की जाती है। जब इसे True पर सेट किया जाता है, तो बॉडी डिफ़ॉल्ट रूप से RTF फ़ॉर्मेट में कनवर्ट हो जाती है। बॉडी को HTML फ़ॉर्मेट में बरकरार रखने के लिए इसे False पर सेट किया जाना चाहिए। नीचे दिया गया कोड उदाहरण दिखाता है कि EML से MSG में रूपांतरण के समय अपॉइंटमेंट की HTML बॉडी कैसे संरक्षित रखी जाए:
import aspose.email as ae
eml = ae.MailMessage.load("appointment.eml")
conversionOptions = ae.mapi.MapiConversionOptions()
conversionOptions.format = ae.mapi.OutlookMessageFormat.UNICODE
# default value for ForcedRtfBodyForAppointment is true
conversionOptions.forced_rtf_body_for_appointment = False
msg = ae.mapi.MapiMessage.from_mail_message(eml, conversionOptions)
print(f"Body Type: {msg.body_type}")
msg.save("appointment.msg")
नियुक्तियों के लिए रिमाइंडर सेट करें
एक रिमाइंडर नियुक्ति बनाई जाने पर जोड़ा जा सकता है। ये अलार्म विभिन्न मानदंडों द्वारा ट्रिगर किए जा सकते हैं — शेड्यूल शुरू होने से n मिनट पहले, n बार दोहराते हुए n अंतराल पर, आदि। एक ICS नियुक्ति में ये ट्रिगर टैग द्वारा वर्णित होते हैं जो सम्मिलित होते हैं BEGIN:VALARM और END:VALARM.
रिमाइंडर सेट करने के लिए टैग जोड़ें
Aspose.Email अलार्म ब्लॉकों को उजागर करता है reminders संग्रह Appointment class और AppointmentReminder, ReminderTrigger, ReminderDuration, ReminderAttachment और ReminderAttendee क्लासेज़। अलार्म का प्रकार द्वारा परिभाषित होता है ReminderAction एन्यूमरेशन — AUDIO, DISPLAY, EMAIL या PROCEDURE.
निम्नलिखित कोड स्निपेट दिखाता है कि एक ही नियुक्ति पर कई रिमाइंडर कैसे सेट करें:
import datetime
import aspose.email as ae
from aspose.email.calendar import (Appointment, AppointmentReminder, ReminderTrigger, ReminderDuration,
ReminderAction, ReminderAttachment, ReminderAttendee, ReminderRelated)
location = "Meeting Location: Room 5"
start_date = datetime.datetime(1997, 3, 18, 18, 30, 0)
end_date = datetime.datetime(1997, 3, 18, 19, 30, 0)
organizer = ae.MailAddress("aaa@amail.com", "Organizer")
attendees = ae.MailAddressCollection()
attendees.append(ae.MailAddress("bbb@bmail.com", "First attendee"))
target = Appointment(location, start_date, end_date, organizer, attendees)
# Audio alarm that will sound at a precise time and repeat 4 more times at 15 minute intervals
audio_reminder = AppointmentReminder()
audio_reminder.trigger = ReminderTrigger(datetime.datetime(1997, 3, 17, 13, 30, 0))
audio_reminder.repeat = 4
audio_reminder.duration = ReminderDuration(datetime.timedelta(minutes=15))
audio_reminder.action = ReminderAction.AUDIO
audio_reminder.attachments.append(ReminderAttachment("ftp://Host.com/pub/sounds/bell-01.aud"))
target.reminders.append(audio_reminder)
# Display alarm that will trigger 30 minutes before the scheduled start of the event
# and will repeat 2 more times at 15 minute intervals
display_reminder = AppointmentReminder()
display_reminder.trigger = ReminderTrigger(ReminderDuration(datetime.timedelta(minutes=-30)), ReminderRelated.START)
display_reminder.repeat = 2
display_reminder.duration = ReminderDuration(datetime.timedelta(minutes=15))
display_reminder.action = ReminderAction.DISPLAY
display_reminder.description = "Breakfast meeting with executive team at 8:30 AM EST"
target.reminders.append(display_reminder)
# Email alarm that will trigger 2 days before the scheduled start. It does not repeat.
email_reminder = AppointmentReminder()
email_reminder.trigger = ReminderTrigger(ReminderDuration(datetime.timedelta(days=-2)), ReminderRelated.START)
email_reminder.attendees.append(ReminderAttendee("john_doe@host.com"))
email_reminder.action = ReminderAction.EMAIL
email_reminder.summary = "REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING"
email_reminder.description = "A draft agenda needs to be sent out to the attendees of the weekly managers meeting."
email_reminder.attachments.append(ReminderAttachment("http://Host.com/templates/agenda.doc"))
target.reminders.append(email_reminder)
target.save("AppointmentWithReminders_out.ics")
MapiCalendarTimeZone सिस्टम टाइमज़ोन से लेकर MapiCalendarTimeZone(TimeZoneInfo) कंस्ट्रक्टर। Aspose.Email for Python via .NET में यह MapiCalendarTimeZone क्लास केवल-रिड है — यह उजागर करता है key_name और time_zone_rules एक टाइमज़ोन के जो पहले से ही कैलेंडर आइटम में संग्रहीत है, और इसे मानक टाइमज़ोन से नहीं बनाया जा सकता।
साथ ही देखें
- आवृत्तियों का प्रबंधन — दैनिक, साप्ताहिक, मासिक और वार्षिक MAPI पुनरावृत्ति पैटर्न बनाएं।