Outlook कैलेंडर आइटम्स का प्रबंधन
यह लेख Outlook को कवर करता है MapiCalendar MSG के रूप में सहेजे गए कैलेंडर आइटम। मानक-आधारित iCalendar (ICS) अपॉइंटमेंट और मीटिंग अनुरोधों के साथ काम करने के लिए, देखें नियोजनों का प्रबंधन; PST के अंदर कैलेंडर आइटम संग्रहीत और पढ़ने के लिए, देखें PST फ़ाइलों में कैलेंडर आइटम्स का प्रबंधन.
Aspose.Email MapiCalendar क्लास विभिन्न कैलेंडर आइटम गुण सेट करने के लिए मेथड्स और एट्रिब्यूट्स प्रदान करता है। इस सेक्शन में कोड उदाहरण दिए गए हैं:
- कैलेंडर आइटम्स बनाएं और सहेजें
- कैलेंडर आइटम्स को MSG फ़ाइलों के रूप में सहेजें
- MAPI कैलेंडर आइटम्स के लिए प्रोडक्ट आईडी को आईसीएस में सहेजें
- घटनाओं की कुल संख्या प्राप्त करें
- डिस्प्ले रिमाइंडर जोड़ें
- ऑडियो रिमाइंडर जोड़ें
- कैलेंडर फ़ाइलों से अटैचमेंट जोड़ें/प्राप्त करें
- मीटिंग अनुरोधों में प्राप्तकर्ताओं की स्थिति जांचें
- मानक समयक्षेत्र से MAPI कैलेंडर टाइमज़ोन बनाएं
- नियुक्तियों के लिए रिमाइंडर सेट करें
- HTML बॉडी के साथ अपॉइंटमेंट EML को MSG में परिवर्तित करें
- MAPI कैलेंडर आइटम्स की स्थिति को मैन्युअली सेट करें
कैलेंडर आइटम्स को बनाएं और सहेजें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर आइटम को ICS फॉर्मेट में कैसे बनाएं और सहेजें।
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Outlook();
// Create the appointment
MapiCalendar calendar = new MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
new DateTime(2012, 10, 2, 13, 0, 0),
new DateTime(2012, 10, 2, 14, 0, 0));
calendar.Save(dataDir + "CalendarItem_out.ics", AppointmentSaveFormat.Ics);
कैलेंडर आइटम्स को MSG फ़ाइलों के रूप में सहेजें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर आइटम को MSG के रूप में कैसे सहेजा जाए।
calendar.Save(dataDir + "CalendarItemAsMSG_out.Msg", AppointmentSaveFormat.Msg);
MAPI कैलेंडर आइटम्स के लिए प्रोडक्ट आईडी को आईसीएस में सहेजें
यह ProductIdentifier की प्रॉपर्टी MapiCalendarIcsSaveOptions क्लास का उपयोग MAPI कैलेंडर आइटम को iCalendar (ICS) फाइल में सहेजने के लिए किया जाता है, जो मूल तिथि और समय जानकारी और एक कस्टम प्रोडक्ट आइडेंटिफ़ायर को संरक्षित रखता है। यह प्रॉपर्टी उस प्रोडक्ट के आइडेंटिफ़ायर को निर्दिष्ट करती है जिसने iCalendar ऑब्जेक्ट बनाया।
निम्नलिखित कोड उदाहरण दिखाता है कि MAPI कैलेंडर ऑब्जेक्ट में iCalendar (ICS) डेटा के साथ कैसे काम किया जाए:
var icsSaveOptions = new MapiCalendarIcsSaveOptions
{
KeepOriginalDateTimeStamp = true,
ProductIdentifier = "Foo Ltd"
};
mapiCalendar.Save("my.ics", icsSaveOptions);
घटनाओं की कुल संख्या प्राप्त करें
यह CalendarReader क्लास कैलेंडर इवेंट्स को सहजता से हैंडल करने में सक्षम बनाता है। निम्नलिखित प्रॉपर्टीज़ और एक मेथड आपको कई इवेंट्स के साथ काम करने की अनुमति देता है:
- CalendarReader.Count - CalendarReader क्लास की Count प्रॉपर्टी आपको कैलेंडर में मौजूद Vevent कॉम्पोनेन्ट्स (इवेंट्स) की संख्या प्राप्त करने की अनुमति देती है, जिससे कुल इवेंट्स की संख्या को ट्रैक करना आसान हो जाता है।
- CalendarReader.IsMultiEvents - यह प्रॉपर्टी निर्धारित करती है कि कैलेंडर में कई इवेंट्स हैं या नहीं। यह एक बूलियन मान प्रदान करती है जो दर्शाता है कि कैलेंडर में एक से अधिक इवेंट हैं, जिससे सिंगल या मल्टीपल इवेंट्स वाले कैलेंडर की पहचान में मदद मिलती है।
- CalendarReader.Method - Method प्रॉपर्टी कैलेंडर ऑब्जेक्ट से जुड़े iCalendar मेथड प्रकार को प्राप्त करती है। यह मेथड प्रकार लौटाती है, जैसे “REQUEST,” “PUBLISH,” या “CANCEL,” जो कैलेंडर के उद्देश्य के बारे में मूल्यवान जानकारी देती है।
- CalendarReader.Version - iCalendar का संस्करण प्राप्त करता है।
- CalendarReader.LoadAsMultiple() यह मेथड कई इवेंट्स वाले कैलेंडर से इवेंट्स की सूची लोड करने में सक्षम बनाता है। यह Appointment ऑब्जेक्ट्स की एक सूची लौटाता है, जिससे प्रत्येक इवेंट तक आसान पहुँच और व्यक्तिगत रूप से प्रोसेसिंग संभव होती है।
निम्नलिखित कोड उदाहरण दर्शाता है कि आप अपने प्रोजेक्ट में इन क्षमताओं को कैसे लागू कर सकते हैं:
var reader = new CalendarReader(fileName);
Console.WriteLine("Calendar contains " + reader.Count + " events");
Console.WriteLine("The Version of the calendar is " + reader.Version);
Console.WriteLine("The Method of the calendar is " + reader.Method);
Console.WriteLine("Does the calendar contain multiple events? - " + reader.IsMultiEvents);
List<Appointment> appointments = reader.LoadAsMultiple();
डिस्प्ले रिमाइंडर जोड़ें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर में डिस्प्ले रिमाइंडर कैसे जोड़ा जाए।
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Outlook();
// Create Appointment
Appointment app = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "organizer@domain.com", "attendee@gmail.com");
MailMessage msg = new MailMessage();
msg.AddAlternateView(app.RequestApointment());
MapiMessage mapi = MapiMessage.FromMailMessage(msg);
MapiCalendar calendar = (MapiCalendar)mapi.ToMapiMessageItem();
// Set calendar Properties
calendar.ReminderSet= true;
calendar.ReminderDelta = 45;//45 min before start of event
string savedFile = (dataDir + "calendarWithDisplayReminder.ics");
calendar.Save(savedFile, AppointmentSaveFormat.Ics);
ऑडियो रिमाइंडर जोड़ें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर में ऑडियो रिमाइंडर कैसे जोड़ें।
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Outlook();
Appointment app = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "organizer@domain.com", "attendee@gmail.com");
MailMessage msg = new MailMessage();
msg.AddAlternateView(app.RequestApointment());
MapiMessage mapi = MapiMessage.FromMailMessage(msg);
MapiCalendar calendar = (MapiCalendar)mapi.ToMapiMessageItem();
// Set calendar properties
calendar.ReminderSet = true;
calendar.ReminderDelta = 58;//58 min before start of event
calendar.ReminderFileParameter = dataDir + "Alarm01.wav";
string savedFile = (dataDir + "calendarWithAudioReminder_out.ics");
calendar.Save(savedFile, AppointmentSaveFormat.Ics);
कैलेंडर फ़ाइलों से अटैचमेंट जोड़ें/प्राप्त करें
निम्नलिखित कोड स्निपेट दिखाता है कि कैलेंडर फ़ाइलों से अटैचमेंट कैसे जोड़ें/प्राप्त करें।
string[] files = new string[3];
files[0] = dataDir + "attachment_1.doc";
files[1] = dataDir + "download.png";
files[2] = dataDir + "Desert.jpg";
Appointment app1 = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "organizer@domain.com", "attendee@gmail.com");
foreach (string file in files)
{
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(file)))
{
app1.Attachments.Add(new Attachment(ms, Path.GetFileName(file)));
}
}
app1.Save(dataDir + "appWithAttachments_out.ics", AppointmentSaveFormat.Ics);
Appointment app2 = Appointment.Load(dataDir + "appWithAttachments_out.ics");
Console.WriteLine(app2.Attachments.Count);
foreach (Attachment att in app2.Attachments)
Console.WriteLine(att.Name);
मीटिंग अनुरोधों में प्राप्तकर्ताओं की स्थिति जांचें
निम्नलिखित कोड स्निपेट दिखाता है कि मीटिंग अनुरोध से प्राप्तकर्ताओं की स्थिति कैसे प्रदर्शित की जाए।
MapiMessage message = MapiMessage.FromFile(fileName);
foreach (MapiRecipient recipient in message.Recipients)
{
Console.WriteLine(recipient.RecipientTrackStatus);
}
मानक टाइमज़ोन से MAPI कैलेंडर टाइमज़ोन बनाएं
निम्नलिखित कोड स्निपेट दिखाता है कि मानक टाइमज़ोन से MapiCalendarTimeZone कैसे बनाया जाए।
MapiCalendarTimeZone timeZone = new MapiCalendarTimeZone(TimeZoneInfo.Local);
नियुक्तियों के लिए रिमाइंडर सेट करें
जब अपॉइंटमेंट बनाया जाता है, तो एक रिमाइंडर जोड़ा जा सकता है। ये अलार्म विभिन्न मानदंडों पर आधारित ट्रिगर हो सकते हैं जैसे शेड्यूल शुरू होने से n मिनट पहले, n अंतराल पर n बार दोहराना। विभिन्न टैगों का उपयोग करके इन ट्रिगर्स को अपॉइंटमेंट के भीतर BEGIN:VALARM और END:VALARM द्वारा घेराए गए स्क्रिप्ट में बनाया जा सकता है। अपॉइंटमेंट पर रिमाइंडर सेट करने के कई वैरिएंट्स होते हैं।
रिमाइंडर सेट करने के लिए टैग जोड़ें
निम्नलिखित कोड स्निपेट दिखाता है कि टैग जोड़कर रिमाइंडर कैसे सेट किया जाए।
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Outlook();
string location = "Meeting Location: Room 5";
DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00),
endDate = new DateTime(1997, 3, 18, 19, 30, 00);
MailAddress organizer = new MailAddress("aaa@amail.com", "Organizer");
MailAddressCollection attendees = new MailAddressCollection();
attendees.Add(new MailAddress("bbb@bmail.com", "First attendee"));
Appointment target = new Appointment(location, startDate, endDate, organizer, attendees);
// Audio alarm that will sound at a precise time and
// Repeat 4 more times at 15 minute intervals:
AppointmentReminder audioReminder = new AppointmentReminder();
audioReminder.Trigger = new ReminderTrigger(new DateTime(1997, 3, 17, 13, 30, 0, DateTimeKind.Utc));
audioReminder.Repeat = 4;
audioReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0));
audioReminder.Action = ReminderAction.Audio;
ReminderAttachment attach = new ReminderAttachment(new Uri("ftp://Host.com/pub/sounds/bell-01.aud"));
audioReminder.Attachments.Add(attach);
target.Reminders.Add(audioReminder);
// Display alarm that will trigger 30 minutes before the
// Scheduled start of the event it is
// Associated with and will repeat 2 more times at 15 minute intervals:
AppointmentReminder displayReminder = new AppointmentReminder();
ReminderDuration dur = new ReminderDuration(new TimeSpan(0, -30, 0));
displayReminder.Trigger = new ReminderTrigger(dur, ReminderRelated.Start);
displayReminder.Repeat = 2;
displayReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0));
displayReminder.Action = ReminderAction.Display;
displayReminder.Description = "Breakfast meeting with executive team at 8:30 AM EST";
target.Reminders.Add(displayReminder);
// Email alarm that will trigger 2 days before the
// Scheduled due date/time. It does not
// Repeat. The email has a subject, body and attachment link.
AppointmentReminder emailReminder = new AppointmentReminder();
ReminderDuration dur1 = new ReminderDuration(new TimeSpan(-2, 0, 0, 0));
emailReminder.Trigger = new ReminderTrigger(dur1, ReminderRelated.Start);
ReminderAttendee attendee = new ReminderAttendee("john_doe@host.com");
emailReminder.Attendees.Add(attendee);
emailReminder.Action = ReminderAction.Email;
emailReminder.Summary = "REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING";
emailReminder.Description = @"A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file.";
ReminderAttachment attach1 = new ReminderAttachment(new Uri("http://Host.com/templates/agenda.doc"));
emailReminder.Attachments.Add(attach1);
target.Reminders.Add(emailReminder);
// Procedural alarm that will trigger at a precise date/time
// And will repeat 23 more times at one hour intervals. The alarm will
// Invoke a procedure file.
AppointmentReminder procReminder = new AppointmentReminder();
procReminder.Trigger = new ReminderTrigger(new DateTime(1998, 1, 1, 5, 0, 0, DateTimeKind.Utc));
procReminder.Repeat = 23;
procReminder.Duration = new ReminderDuration(new TimeSpan(1, 0, 0));
procReminder.Action = ReminderAction.Procedure;
ReminderAttachment attach2 = new ReminderAttachment(new Uri("ftp://Host.com/novo-procs/felizano.exe"));
procReminder.Attachments.Add(attach2);
target.Reminders.Add(procReminder);
target.Save(dataDir + "savedFile_out.ics");
HTML बॉडी के साथ अपॉइंटमेंट EML को MSG में परिवर्तित करें
वर्ज़न 19.3 से, Aspose.Email यह क्षमता प्रदान करता है कि अपॉइंटमेंट EML को MSG में परिवर्तित किया जा सके जबकि अपॉइंटमेंट के HTML बॉडी को बरकरार रखा जाए। Aspose.Email एक MapiConversionOptions.ForcedRtfBodyForAppointment प्रॉपर्टी जिसकी डिफ़ॉल्ट वैल्यू true. है। जब वैल्यू MapiConversionOptions.ForcedRtfBodyForAppointment यदि true पर सेट किया जाता है, तो अपॉइंटमेंट बॉडी RTF फॉर्मेट में परिवर्तित हो जाता है। अपॉइंटमेंट बॉडी फॉर्मेट को HTML फॉर्मेट में रखने के लिए, मान सेट करें MapiConversionOptions.ForcedRtfBodyForAppointment को false.
निम्नलिखित उदाहरण उपयोग को दर्शाता है MapiConversionOptions.ForcedRtfBodyForAppointment ऐपॉइंटमेंट बॉडी फॉर्मेट को HTML फॉर्मेट में रखने के लिए प्रॉपर्टी।
// Outlook directory
string dataDir = RunExamples.GetDataDir_Outlook();
MailMessage mailMessage = MailMessage.Load(dataDir + "TestAppointment.eml");
MapiConversionOptions conversionOptions = new MapiConversionOptions();
conversionOptions.Format = OutlookMessageFormat.Unicode;
// default value for ForcedRtfBodyForAppointment is true
conversionOptions.ForcedRtfBodyForAppointment = false;
MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage, conversionOptions);
Console.WriteLine("Body Type: " + mapiMessage.BodyType);
mapiMessage.Save(dataDir + "TestAppointment_out.msg");
MAPI कैलेंडर आइटम्स की स्थिति मैन्युअली सेट करें
एक MAPI कैलेंडर ऑब्जेक्ट की स्थिति को स्पष्ट रूप से सेट करें, डिफ़ॉल्ट व्यवहार को ओवरराइड करते हुए। यह कैलेंडर इवेंट की स्थितियों पर बेहतर नियंत्रण प्रदान करता है, विशेष रूप से प्राप्त मीटिंग अनुरोधों को संभालते समय। डिफ़ॉल्ट रूप से, जब कोई मीटिंग बनाई जाती है, इसकी स्थिति होती है MapiCalendarState.Meeting. जब प्राप्तकर्ता के इनबॉक्स में प्राप्त होता है, तो यह स्वतः बदल जाता है MapiCalendarState.Received, और इसका संदेश वर्ग “IPM.Schedule.Meeting.Request” में अपडेट किया गया है। उपयोग करके SetStateForced Received स्थिति को मैन्युअली सेट करने की अनुमति देता है, जो कैलेंडर को MSG फ़ाइल के रूप में सहेजते समय आयोजक जानकारी को संरक्षित करने में उपयोगी हो सकता है। हालांकि, इससे मीटिंग को सही ढंग से फॉरवर्ड या री‑सेंड करने में बाधा आ सकती है।
नीचे का कोड नमूना दिखाता है कि कैसे बनाया जाए MapiCalendar ऑब्जेक्ट, एक आयोजक असाइन करें, और स्पष्ट रूप से उसकी स्थिति दोनों पर सेट करें Meeting और Received का उपयोग करके SetStateForced. फिर यह कैलेंडर आइटम को .msg फ़ाइल के रूप में सहेजता है।
MapiCalendar appointment = new MapiCalendar(
"LAKE ARGYLE WA 6743",
"Appointment",
"This is a very important meeting :)",
new DateTime(2024, 5, 10, 12, 30, 0, DateTimeKind.Utc),
new DateTime(2024, 5, 10, 13, 30, 0, DateTimeKind.Utc));
appointment.Organizer = new MapiElectronicAddress
{
EmailAddress = "test@aaa.com",
DisplayName = "test display Name"
};
appointment.SetStateForced(MapiCalendarState.Meeting | MapiCalendarState.Received);
appointment.Save("appointment.msg", AppointmentSaveFormat.Msg);
साथ ही देखें
- नियोजनों का प्रबंधन — iCalendar (ICS) अपॉइंटमेंट और मीटिंग अनुरोधों के साथ काम करें।
- PST फ़ाइलों में कैलेंडर आइटम्स का प्रबंधन — PST के अंदर कैलेंडर आइटम संग्रहीत और पढ़ें।