public static void Run() { // ExStart:CreateREAndFWMessages string dataDir = RunExamples.GetDataDir_Exchange(); const string mailboxUri = "https://exchange.domain.com/ews/Exchange.asmx"; const string domain = @""; const string username = @"username"; const string password = @"password"; NetworkCredential credential = new NetworkCredential(username, password, domain); IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credential); try { MailMessage message = new MailMessage("*****@*****.**", "*****@*****.**", "TestMailRefw - " + Guid.NewGuid().ToString(), "TestMailRefw Implement ability to create RE and FW messages from source MSG file"); client.Send(message); ExchangeMessageInfoCollection messageInfoCol = client.ListMessages(client.MailboxInfo.InboxUri); if (messageInfoCol.Count == 1) { Console.WriteLine("1 message in Inbox"); } else { Console.WriteLine("Error! No message in Inbox"); } MailMessage message1 = new MailMessage("*****@*****.**", "*****@*****.**", "TestMailRefw - " + Guid.NewGuid().ToString(), "TestMailRefw Implement ability to create RE and FW messages from source MSG file"); client.Send(message1); messageInfoCol = client.ListMessages(client.MailboxInfo.InboxUri); if (messageInfoCol.Count == 2) { Console.WriteLine("2 messages in Inbox"); } else { Console.WriteLine("Error! No new message in Inbox"); } MailMessage message2 = new MailMessage("*****@*****.**", "*****@*****.**", "TestMailRefw - " + Guid.NewGuid().ToString(), "TestMailRefw Implement ability to create RE and FW messages from source MSG file"); message2.Attachments.Add(Attachment.CreateAttachmentFromString("Test attachment 1", "Attachment Name 1")); message2.Attachments.Add(Attachment.CreateAttachmentFromString("Test attachment 2", "Attachment Name 2")); // Reply, Replay All and forward Message client.Reply(message2, messageInfoCol[0]); client.ReplyAll(message2, messageInfoCol[0]); client.Forward(message2, messageInfoCol[0]); } catch (Exception ex) { Console.WriteLine("Error in program" + ex.Message); } // ExEnd:CreateREAndFWMessages }
public static void Run() { // ExStart:SynchronizeFolderItems IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); MailMessage message1 = new MailMessage("*****@*****.**", "*****@*****.**", "EMAILNET-34738 - " + Guid.NewGuid().ToString(), "EMAILNET-34738 Sync Folder Items"); client.Send(message1); MailMessage message2 = new MailMessage("*****@*****.**", "*****@*****.**", "EMAILNET-34738 - " + Guid.NewGuid().ToString(), "EMAILNET-34738 Sync Folder Items"); client.Send(message2); ExchangeMessageInfoCollection messageInfoCol = client.ListMessages(client.MailboxInfo.InboxUri); SyncFolderResult result = client.SyncFolder(client.MailboxInfo.InboxUri, null); Console.WriteLine(result.NewItems.Count); Console.WriteLine(result.ChangedItems.Count); Console.WriteLine(result.ReadFlagChanged.Count); Console.WriteLine(result.DeletedItems.Length); // ExEnd:SynchronizeFolderItems }
public static void Run() { try { // ExStart:SendTaskRequestUsingIEWSClient string dataDir = RunExamples.GetDataDir_Exchange(); // Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); MsgLoadOptions options = new MsgLoadOptions(); options.PreserveTnefAttachments = true; // load task from .msg file MailMessage eml = MailMessage.Load(dataDir + "task.msg", options); eml.From = "*****@*****.**"; eml.To.Clear(); eml.To.Add(new MailAddress("*****@*****.**")); client.Send(eml); // ExEnd:SendTaskRequestUsingIEWSClient } catch (Exception ex) { Console.Write(ex.Message); } }
public static void Run() { try { // Set mailboxURI, Username, password, domain information string mailboxUri = "https://ex2010/ews/exchange.asmx"; string username = "******"; string password = "******"; string domain = "ex2010.local"; NetworkCredential credentials = new NetworkCredential(username, password, domain); IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); // ExStart:SendEmailToPrivateDistributionList ExchangeDistributionList[] distributionLists = client.ListDistributionLists(); MailAddress distributionListAddress = distributionLists[0].ToMailAddress(); MailMessage message = new MailMessage(new MailAddress("*****@*****.**"), distributionListAddress); message.Subject = "sendToPrivateDistributionList"; client.Send(message); // ExEnd:SendEmailToPrivateDistributionList } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Run() { // The path to the File directory. string dataDir = RunExamples.GetDataDir_Exchange(); string dstEmail = dataDir + "Message.eml"; // Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); // load task from .eml file EmlLoadOptions loadOptions = new EmlLoadOptions(); loadOptions.PrefferedTextEncoding = Encoding.UTF8; loadOptions.PreserveTnefAttachments = true; // load task from .msg file MailMessage eml = MailMessage.Load(dstEmail, loadOptions); eml.From = "*****@*****.**"; eml.To.Clear(); eml.To.Add(new MailAddress("*****@*****.**")); client.Send(eml); Console.WriteLine(Environment.NewLine + "Task sent on Exchange Server successfully."); }
public static void Run() { try { // ExStart: SendCalendarInvitation using (IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain")) { // delegate calendar access permission ExchangeDelegateUser delegateUser = new ExchangeDelegateUser("*****@*****.**", ExchangeDelegateFolderPermissionLevel.NotSpecified); delegateUser.FolderPermissions.CalendarFolderPermissionLevel = ExchangeDelegateFolderPermissionLevel.Reviewer; client.DelegateAccess(delegateUser, "*****@*****.**"); // Create invitation MapiMessage mapiMessage = client.CreateCalendarSharingInvitationMessage("*****@*****.**"); MailConversionOptions options = new MailConversionOptions(); options.ConvertAsTnef = true; MailMessage mail = mapiMessage.ToMailMessage(options); client.Send(mail); } // ExEnd: SendCalendarInvitation } catch (Exception ex) { Console.WriteLine(ex.Message); } }
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 }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Exchange(); string dstEmail = dataDir + "Message.msg"; // Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); MailMessageLoadOptions loadOptions = new MailMessageLoadOptions(); loadOptions.MessageFormat = MessageFormat.Msg; loadOptions.FileCompatibilityMode = FileCompatibilityMode.PreserveTnefAttachments; // load task from .msg file MailMessage eml = MailMessage.Load(dstEmail, loadOptions); eml.From = "*****@*****.**"; eml.To.Clear(); eml.To.Add(new Aspose.Email.Mail.MailAddress("*****@*****.**")); client.Send(eml); Console.WriteLine(Environment.NewLine + "Task sent on Exchange Server successfully."); }
public static void Run() { // ExStart: SendCalendarInvitation /// <summary> /// This exmpale shows how an Exchange user can share his/her calendar with someone using the EWS client of the API. /// Available from Aspose.Email for .NET 6.4.0 onwards /// </summary> using (IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain")) { // delegate calendar access permission ExchangeDelegateUser delegateUser = new ExchangeDelegateUser("*****@*****.**", ExchangeDelegateFolderPermissionLevel.NotSpecified); delegateUser.FolderPermissions.CalendarFolderPermissionLevel = ExchangeDelegateFolderPermissionLevel.Reviewer; client.DelegateAccess(delegateUser, "*****@*****.**"); // Create invitation MapiMessage mapiMessage = client.CreateCalendarSharingInvitationMessage("*****@*****.**"); // send invitation MailMessageInterpretor messageInterpretor = MailMessageInterpretorFactory.Instance.GetIntepretor(mapiMessage.MessageClass); MailMessage mailMessage = messageInterpretor.InterpretAsTnef(mapiMessage); client.Send(mailMessage); } // ExEnd: SendCalendarInvitation }
public static void Run() { //ExStart: GetUriOfSentEmail using (IEWSClient client = EWSClient.GetEWSClient("https://exchange.office365.com/ews/exchange.asmx", "username", "password")) { // Register the event handler client.ItemSent += new EventHandler <SentItemEventArgs>(ItemSentHandler); MailMessage eml = new MailMessage("*****@*****.**", "*****@*****.**", "test message", "This is a test message"); client.Send(eml); } //ExEnd: GetUriOfSentEmail }
public static void Run() { // ExStart:CreateAndSendingMessageWithVotingOptions string address = "*****@*****.**"; IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); MailMessage message = CreateTestMessage(address); // Set FollowUpOptions Buttons FollowUpOptions options = new FollowUpOptions(); options.VotingButtons = "Yes;No;Maybe;Exactly!"; client.Send(message, options); // ExEnd:CreateAndSendingMessageWithVotingOptions }
public static void Run() { // ExStart:SendEmailMessagesUsingExchangeServer // Create instance of IEWSClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); // Create instance of type MailMessage MailMessage msg = new MailMessage(); msg.From = "*****@*****.**"; msg.To = "recipient@ domain.com "; msg.Subject = "Sending message from exchange server"; msg.HtmlBody = "<h3>sending message from exchange server</h3>"; // Send the message client.Send(msg); // ExEnd:SendEmailMessagesUsingExchangeServer }
private void button2_Click(object sender, EventArgs e) { //https://outlook.ncs.corp.int-ads/ews/Services.wsdl // ExStart:SendEmailMessagesUsingExchangeServer // Create instance of IEWSClient class by giving credentials //IEWSClient client = EWSClient.GetEWSClient("https://outlook.ncs.corp.int-ads/ews/Services.wsdl", "ranelaa", "_pa55111", "ncs"); const string mailboxUri = "https://outlook.ncs.corp.int-ads/ews/Services.wsdl"; //const string mailboxUri = "https://outlook.ncs.corp.int-ads"; const string domain = @"ncs"; const string username = @"ranelaa"; const string password = @"_pa55111"; NetworkCredential credentials = new NetworkCredential(username, password, domain); IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); // Create instance of type MailMessage MailMessage msg = new MailMessage(); msg.Sender = "*****@*****.**"; msg.From = "*****@*****.**"; msg.To = "*****@*****.**"; msg.Subject = "Hrconnect2 Mail -Aspose EWS"; msg.HtmlBody = "<h3>sending message from exchange server</h3>"; // Send the message try { // Send the message client.Send(msg); } catch (Exception ex) { //throw ex; Console.Write(ex.Message); } //ExEnd:SendEmailMessagesUsingExchangeServer }
public static void Run() { // ExStart:SendTaskRequestUsingIEWSClient string dataDir = RunExamples.GetDataDir_Exchange(); // Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); MailMessageLoadOptions loadOptions = new MailMessageLoadOptions(); loadOptions.MessageFormat = MessageFormat.Msg; loadOptions.FileCompatibilityMode = FileCompatibilityMode.PreserveTnefAttachments; // load task from .msg file MailMessage eml = MailMessage.Load(dataDir + "task.msg", loadOptions); eml.From = "*****@*****.**"; eml.To.Clear(); eml.To.Add(new MailAddress("*****@*****.**")); client.Send(eml); // ExEnd:SendTaskRequestUsingIEWSClient }