Example #1
0
        static void Main(string[] args)
        {
            // Create attendees of the meeting
            MailAddressCollection attendees = new MailAddressCollection();
            attendees.Add("*****@*****.**");
            attendees.Add("*****@*****.**");

            // Set up appointment
            Appointment app = new Appointment(
                "Location", // location of meeting
                DateTime.Now, // start date
                DateTime.Now.AddHours(1), // end date
                new MailAddress("*****@*****.**"), // organizer
                attendees); // attendees

            // Set up message that needs to be sent
            MailMessage msg = new MailMessage();
            msg.From = "*****@*****.**";
            msg.To = "*****@*****.**";
            msg.Subject = "appointment request";
            msg.Body = "you are invited";

            // Add meeting request to the message
            msg.AddAlternateView(app.RequestApointment());

            // Set up the SMTP client to send email with meeting request
            SmtpClient client = new SmtpClient("host", 25, "user", "password");
            client.Send(msg);
        }
Example #2
0
        public static void Run()
        {
            // The path to the File directory.
            string dataDir  = RunExamples.GetDataDir_SMTP();
            string dstEmail = dataDir + "outputAttachments.msg";

            // Create an instance of the MailMessage class
            MailMessage msg = new MailMessage();

            // Set the sender, recipient, who will receive the meeting request. Basically, the recipient is the same as the meeting attendees
            msg.From = "*****@*****.**";
            msg.To   = "[email protected], [email protected], [email protected], [email protected]";

            // Create Appointment instance
            Appointment app = new Appointment("Room 112", new DateTime(2015, 7, 17, 13, 0, 0), new DateTime(2015, 7, 17, 14, 0, 0), msg.From, msg.To);

            app.Summary     = "Release Meetting";
            app.Description = "Discuss for the next release";

            // Add appointment to the message and Create an instance of SmtpClient class
            msg.AddAlternateView(app.RequestApointment());
            SmtpClient client = GetSmtpClient();

            try
            {
                // Client.Send will send this message
                client.Send(msg);
                Console.WriteLine("Message sent");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            Console.WriteLine(Environment.NewLine + "Meeting request send successfully.");
        }
Example #3
0
        public static void Run()
        {
            // ExStart:DraftAppointmentRequest
            // The path to the File directory.
            string dataDir  = RunExamples.GetDataDir_Email();
            string dstDraft = dataDir + "appointment-draft_out.msg";

            string sender    = "*****@*****.**";
            string recipient = "*****@*****.**";

            MailMessage message = new MailMessage(sender, recipient, string.Empty, string.Empty);

            Appointment app = new Appointment(string.Empty, DateTime.Now, DateTime.Now, sender, recipient)
            {
                MethodType = AppointmentMethodType.Publish
            };

            message.AddAlternateView(app.RequestApointment());

            MapiMessage msg = MapiMessage.FromMailMessage(message);

            // Save the appointment as draft.
            msg.Save(dstDraft);

            Console.WriteLine(Environment.NewLine + "Draft saved at " + dstDraft);
            // ExEnd:DraftAppointmentRequest
        }
        public static void Run()
        {
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_SMTP();
            string dstEmail = dataDir + "outputAttachments.msg";

            // Create an instance of the MailMessage class
            MailMessage msg = new MailMessage();

            // Set the sender, recipient, who will receive the meeting request. Basically, the recipient is the same as the meeting attendees
            msg.From = "*****@*****.**";
            msg.To = "[email protected], [email protected], [email protected], [email protected]";

            // Create Appointment instance
            Appointment app = new Appointment("Room 112", new DateTime(2015, 7, 17, 13, 0, 0), new DateTime(2015, 7, 17, 14, 0, 0), msg.From, msg.To);
            app.Summary = "Release Meetting";
            app.Description = "Discuss for the next release";

            // Add appointment to the message and Create an instance of SmtpClient class
            msg.AddAlternateView(app.RequestApointment());
            SmtpClient client = GetSmtpClient();

            try
            {
                // Client.Send will send this message
                client.Send(msg);
                Console.WriteLine("Message sent");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            Console.WriteLine(Environment.NewLine + "Meeting request send successfully.");
        }
Example #5
0
        static void Main(string[] args)
        {
            // Create attendees of the meeting
            MailAddressCollection attendees = new MailAddressCollection();

            attendees.Add("*****@*****.**");
            attendees.Add("*****@*****.**");

            // Set up appointment
            Appointment app = new Appointment(
                "Location",                              // location of meeting
                DateTime.Now,                            // start date
                DateTime.Now.AddHours(1),                // end date
                new MailAddress("*****@*****.**"), // organizer
                attendees);                              // attendees

            // Set up message that needs to be sent
            MailMessage msg = new MailMessage();

            msg.From    = "*****@*****.**";
            msg.To      = "*****@*****.**";
            msg.Subject = "appointment request";
            msg.Body    = "you are invited";

            // Add meeting request to the message
            msg.AddAlternateView(app.RequestApointment());

            // Set up the SMTP client to send email with meeting request
            SmtpClient client = new SmtpClient("host", 25, "user", "password");

            client.Send(msg);
        }
        public static void Run()
        {
            // ExStart:SendMeetingRequestsUsingEWS
            try
            {
                // Create instance of IEWSClient class by giving credentials
                IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

                // create the meeting request
                Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "*****@*****.**", "*****@*****.**");
                app.Summary     = "meeting request summary";
                app.Description = "description";
                // set recurrence pattern for this appointment
                RecurrencePattern pattern = new DailyRecurrencePattern(DateTime.Now.AddDays(5));
                app.RecurrencePattern = pattern;

                // create the message and set the meeting request
                MailMessage msg = new MailMessage();
                msg.From       = "*****@*****.**";
                msg.To         = "*****@*****.**";
                msg.IsBodyHtml = true;
                msg.HtmlBody   = "<h3>HTML Heading</h3><p>Email Message detail</p>";
                msg.Subject    = "meeting request";
                msg.AddAlternateView(app.RequestApointment(0));

                // send the appointment
                client.Send(msg);
                Console.WriteLine("Appointment request sent");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            // ExEnd:SendMeetingRequestsUsingEWS
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // ExStart:CancelMeetingRequest
            try
            {
                OpenConnection();

                // Get the message ID of the selected row
                string strMessageID = dgMeetings.SelectedRows[0].Cells["MessageID"].Value.ToString();

                // Get the message and calendar information from the database get the attendee information
                string strSQLGetAttendees = "SELECT * FROM Attendent WHERE MessageID = '" + strMessageID + "' ";

                // Get the attendee information in reader
                SqlDataReader rdAttendees = ExecuteReader(strSQLGetAttendees);

                // Create a MailAddressCollection from the attendees found in the database
                MailAddressCollection attendees = new MailAddressCollection();
                while (rdAttendees.Read())
                {
                    attendees.Add(new MailAddress(rdAttendees["EmailAddress"].ToString(), rdAttendees["DisplayName"].ToString()));
                }

                rdAttendees.Close();

                // Get message and calendar information
                string strSQLGetMessage = "SELECT * FROM [Message] WHERE MessageID = '" + strMessageID + "' ";

                // Get the reader for the above query
                SqlDataReader rdMessage = ExecuteReader(strSQLGetMessage);
                rdMessage.Read();

                // Create the Calendar object from the database information
                Appointment app = new Appointment(rdMessage["CalLocation"].ToString(), rdMessage["CalSummary"].ToString(), rdMessage["CalDescription"].ToString(),
                                                  DateTime.Parse(rdMessage["CalStartTime"].ToString()), DateTime.Parse(rdMessage["CalEndTime"].ToString()), new MailAddress(rdMessage["FromEmailAddress"].ToString(), rdMessage["FromDisplayName"].ToString()), attendees);

                // Create message and Set from and to addresses and Add the cancel meeting request
                MailMessage msg = new MailMessage();
                msg.From    = new MailAddress(rdMessage["FromEmailAddress"].ToString(), "");
                msg.To      = attendees;
                msg.Subject = "Cencel meeting";
                msg.AddAlternateView(app.CancelAppointment());
                SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587, "*****@*****.**", "password");
                smtp.Send(msg);
                MessageBox.Show("cancellation request successfull");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            // ExEnd:CancelMeetingRequest
        }
    private void SendEmail()
    {
        try
        {
            // Build message
            MailMessage msg = new MailMessage();
            msg.From = txtFrom.Text;
            // add recipients
            msg.To = txtTo.Text;

            msg.Subject = txtSubject.Text;
            msg.TextBody = txtTextBody.Text;

            // build meeting request
            Appointment app = new Appointment(
                txtLocation.Text, // location
                txtSummary.Text, // summary
                txtDescription.Text, // description
                DateTime.Parse(txtStartDate.Text + " " + txtStartTime.Text), // start date/time
                DateTime.Parse(txtEndDate.Text + " " + txtEndTime.Text), // end date/time
                new MailAddress(txtFrom.Text), // organizer
                msg.To); // attendees

            // attach meeting request to the message
            msg.AddAlternateView(app.RequestApointment());

            // Send message
            SmtpClient smtp = new SmtpClient(
                txtHost.Text,
                int.Parse(txtPort.Text),
                txtUsername.Text,
                txtPassword.Text);

            // SSL settings
            if (chSSL.Checked == true)
            {
                smtp.EnableSsl = true;
                smtp.SecurityMode = SmtpSslSecurityMode.Explicit;
            }

            smtp.Send(msg);

            // show message on screen that email has been sent
            lblMessage.ForeColor = System.Drawing.Color.Green;
            lblMessage.Text = "Meeting request sent successfully in email.<br><hr>";
        }
        catch (Exception ex)
        {
            // display error message
            lblMessage.ForeColor = System.Drawing.Color.Red;
            lblMessage.Text = "Error: " + ex.Message + "<br><hr>";
        }
    }
        // ExStart:SendMeetingRequests
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                // Create an instance of SMTPClient
                SmtpClient client = new SmtpClient(txtMailServer.Text, txtUsername.Text, txtPassword.Text);
                // Get the attendees
                MailAddressCollection attendees = new MailAddressCollection();
                foreach (DataGridViewRow row in dgAttendees.Rows)
                {
                    if (row.Cells["EmailAddress"].Value != null)
                    {
                        // Get names and addresses from the grid and add to MailAddressCollection
                        attendees.Add(new MailAddress(row.Cells["EmailAddress"].Value.ToString(),
                                                      row.Cells["FirstName"].Value.ToString() + " " + row.Cells["LastName"].Value.ToString()));
                    }
                }

                // Create an instance of MailMessage for sending the invitation
                MailMessage msg = new MailMessage();

                // Set from address, attendees
                msg.From = txtFrom.Text;
                msg.To   = attendees;

                // Create am instance of Appointment
                Appointment app = new Appointment(txtLocation.Text, dtTimeFrom.Value, dtTimeTo.Value, txtFrom.Text, attendees);
                app.Summary     = "Monthly Meeting";
                app.Description = "Please confirm your availability.";
                msg.AddAlternateView(app.RequestApointment());

                // Save the info to the database
                if (SaveIntoDB(msg, app) == true)
                {
                    // Save the message and Send the message with the meeting request
                    msg.Save(msg.MessageId + ".eml", SaveOptions.DefaultEml);
                    client.Send(msg);
                    MessageBox.Show("message sent");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        // ExStart:SendAppointmentUpdateRequest
        static public void EMAIL_UPDATE_RECURRENCE(String szUniqueId)
        {
            System.DateTime StartDate = new DateTime(2013, 12, 12, 17, 0, 0);
            System.DateTime EndDate   = new DateTime(2013, 12, 12, 17, 30, 0);
            Appointment     appUpdate = new Appointment("Different Place", StartDate,
                                                        EndDate, "*****@*****.**", "*****@*****.**");

            appUpdate.UniqueId = szUniqueId;
            WeeklyRecurrencePattern pattern3 = (WeeklyRecurrencePattern)appUpdate.Recurrence;

            appUpdate.Summary     = "update meeting request summary";
            appUpdate.Description = "update";
            MailMessage msgUpdate = new MailMessage("*****@*****.**", "*****@*****.**", "06 - test email - update meeting request", "test email");

            msgUpdate.AddAlternateView(appUpdate.UpdateAppointment());
            SmtpClient smtp = new SmtpClient("server.domain.com", 587, "username", "password");

            smtp.Send(msgUpdate);
        }
        public static void Run()
        {
            // ExStart:AddAudioReminderToCalendar
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();
            Appointment app = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "*****@*****.**", "*****@*****.**");

            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);
            // ExEnd:AddAudioReminderToCalendar
        }
        // ExStart:GeneratingOccurrencesFromRecurrencePatterns
        public static void GetOccurences()
        {
            // The path to the File directory
            string        dataDir       = RunExamples.GetDataDir_KnowledgeBase();
            string        tempFileName  = dataDir + "Sample.pst";
            Appointment   appointment   = CreateAppointment();
            MailMessage   mailMessage   = CreateMessage();
            AlternateView alternateView = appointment.RequestApointment();

            mailMessage.AddAlternateView(alternateView);
            MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage);

            using (PersonalStorage pst = PersonalStorage.Create(tempFileName, FileFormatVersion.Unicode))
            {
                FolderInfo folder = pst.RootFolder.AddSubFolder("Calendar");
                folder.AddMessage(mapiMessage);
            }

            using (PersonalStorage pst = PersonalStorage.FromFile(tempFileName))
            {
                var folder = pst.RootFolder.GetSubFolder("Calendar");
                foreach (MessageInfo messageInfo in folder.GetContents())
                {
                    MapiMessage  message = pst.ExtractMessage(messageInfo);
                    MapiCalendar meeting = (MapiCalendar)message.ToMapiMessageItem();
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        meeting.Save(memoryStream);
                        string             s = StreamToString(memoryStream);
                        CalendarRecurrence recurrencePattern = new CalendarRecurrence(s);
                        DateCollection     occurrences       = recurrencePattern.GenerateOccurrences();
                        foreach (DateTime occurrence in occurrences)
                        {
                            Console.WriteLine("{0}", occurrence);
                        }
                    }
                }
            }

            File.Delete(tempFileName);
        }
Example #13
0
        public static void Run()
        {
            // ExStart:AddAudioReminderToCalendar
            // The path to the File directory.
            string      dataDir = RunExamples.GetDataDir_Outlook();
            Appointment app     = new Appointment("Home", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1), "*****@*****.**", "*****@*****.**");

            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);
            // ExEnd:AddAudioReminderToCalendar
        }
        public static void Run()
        {
            // ExStart:SendMeetingRequestsUsingExchangeServer
            try
            {
                string mailboxUri = @"https://ex07sp1/exchange/administrator"; // WebDAV
                string domain = @"litwareinc.com";
                string username = @"administrator";
                string password = @"Evaluation1";

                NetworkCredential credential = new NetworkCredential(username, password, domain);
                Console.WriteLine("Connecting to Exchange server.....");
                // Connect to Exchange Server
                ExchangeClient client = new ExchangeClient(mailboxUri, credential); // WebDAV

                // Create the meeting request
                Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "administrator@" + domain, "bob@" + domain);
                app.Summary = "meeting request summary";
                app.Description = "description";

                // Create the message and set the meeting request
                MailMessage msg = new MailMessage();
                msg.From = "administrator@" + domain;
                msg.To = "bob@" + domain;
                msg.IsBodyHtml = true;
                msg.HtmlBody = "<h3>HTML Heading</h3><p>Email Message detail</p>";
                msg.Subject = "meeting request";
                msg.AddAlternateView(app.RequestApointment(0));

                // Send the appointment
                client.Send(msg);
                Console.WriteLine("Appointment request sent");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            // ExEnd:SendMeetingRequestsUsingExchangeServer
        }        
        public static void Run()
        {
            // ExStart:SendMeetingRequestsUsingExchangeServer
            try
            {
                string mailboxUri = @"https://ex07sp1/exchange/administrator"; // WebDAV
                string domain     = @"litwareinc.com";
                string username   = @"administrator";
                string password   = @"Evaluation1";

                NetworkCredential credential = new NetworkCredential(username, password, domain);
                Console.WriteLine("Connecting to Exchange server.....");
                // Connect to Exchange Server
                ExchangeClient client = new ExchangeClient(mailboxUri, credential); // WebDAV

                // Create the meeting request
                Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "administrator@" + domain, "bob@" + domain);
                app.Summary     = "meeting request summary";
                app.Description = "description";

                // Create the message and set the meeting request
                MailMessage msg = new MailMessage();
                msg.From       = "administrator@" + domain;
                msg.To         = "bob@" + domain;
                msg.IsBodyHtml = true;
                msg.HtmlBody   = "<h3>HTML Heading</h3><p>Email Message detail</p>";
                msg.Subject    = "meeting request";
                msg.AddAlternateView(app.RequestApointment(0));

                // Send the appointment
                client.Send(msg);
                Console.WriteLine("Appointment request sent");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            // ExEnd:SendMeetingRequestsUsingExchangeServer
        }
        public static void Run()
        {
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Email();
            string dstDraft = dataDir + "appointment-draft_out.msg";
            
            string sender = "*****@*****.**";
            string recipient = "*****@*****.**";

            MailMessage message = new MailMessage(sender, recipient, string.Empty, string.Empty);

            Appointment app = new Appointment(string.Empty, DateTime.Now, DateTime.Now, sender, recipient);
            app.Method = AppointmentMethodType.Publish;

            message.AddAlternateView(app.RequestApointment());

            MapiMessage msg = MapiMessage.FromMailMessage(message);

            // Save the appointment as draft.
            msg.Save(dstDraft);

            Console.WriteLine(Environment.NewLine + "Draft saved at " + dstDraft);
        }
        public static void Run()
        {
            // ExStart:SendMeetingRequestsUsingEWS
            try
            {
                // Create instance of IEWSClient class by giving credentials
                IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

                // Create the meeting request
                Appointment app = new Appointment("meeting request", DateTime.Now.AddHours(1), DateTime.Now.AddHours(1.5), "*****@*****.**", "*****@*****.**");
                app.Summary = "meeting request summary";
                app.Description = "description";


                Aspose.Email.Recurrences.RecurrencePattern pattern = new Recurrences.DailyRecurrencePattern(DateTime.Now.AddDays(5));
                app.Recurrence = pattern;

                // Create the message and set the meeting request
                MailMessage msg = new MailMessage();
                msg.From = "*****@*****.**";
                msg.To = "*****@*****.**";
                msg.IsBodyHtml = true;
                msg.HtmlBody = "<h3>HTML Heading</h3><p>Email Message detail</p>";
                msg.Subject = "meeting request";
                msg.AddAlternateView(app.RequestApointment(0));

                // send the appointment
                client.Send(msg);
                Console.WriteLine("Appointment request sent");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            // ExEnd:SendMeetingRequestsUsingEWS
        }        
Example #18
0
 public static MailMessage AddBody(this MailMessage message, string body)
 {
     return(message.AddAlternateView(body));
 }