private static async System.Threading.Tasks.Task Run() { var configuration = new ConfigurationBuilder() .AddUserSecrets("a8aa09bf-0683-4154-81b4-9fd6392e0a74") .Build(); var webCredentials = new WebCredentials(configuration["Username"], configuration["Password"]); var impersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, configuration["Email"]); var uri = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); var service = new ExchangeService(ExchangeVersion.Exchange2010_SP1) { ImpersonatedUserId = impersonatedUserId, Credentials = webCredentials, Url = uri }; var folderId = new FolderId(WellKnownFolderName.Calendar); var propertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Start, AppointmentSchema.AppointmentType); var syncFolder = await service.SyncFolderItems(folderId, propertySet, null, 512, SyncFolderItemsScope.NormalItems, null); foreach (var itemChange in syncFolder) { if (itemChange.Item is Appointment appointment && appointment.AppointmentType == AppointmentType.RecurringMaster) { var collection = await OccurrenceCollection.Bind(service, appointment.Id); foreach (var item in collection) { Console.WriteLine(item.Start.ToString("g")); } } } }
//"*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" public OutlookController(netflix_prContext context) { _context = context; ExchangeService _service = new ExchangeService(); ExchangeCredentials _credentials = new WebCredentials("*****@*****.**", "N3ljcJ2d1HJtfQn0YJjS"); _service.Credentials = (_credentials); _service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); foreach (string user in _Users) { var userMailbox = new Mailbox(user); var folderId = new FolderId(WellKnownFolderName.Tasks, userMailbox); ItemView itemView = new ItemView(int.MaxValue); var userItems = _service.FindItems(folderId, itemView); var employee = (from p in _context.Employe where p.O365Id == user select p).First(); if (userItems.Result == null) { continue; } //List<WrongProject> tasksWithWrongProjectId = CreateTask(userItems, employee); //if (tasksWithWrongProjectId.Any()) //{ // //SendModificationEmail(employee, tasksWithWrongProjectId); //} } //if (projectIds.Any()) //{ // RecalculatCompletionPercentage(); //} }
static void Main(string[] args) { var service = new ExchangeService { Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx") }; //service.AutodiscoverUrl("*****@*****.**", Redirect); var credentials = new WebCredentials("*****@*****.**", "password"); service.Credentials = credentials; var subscription = service.SubscribeToStreamingNotifications(new FolderId[] { WellKnownFolderName.Inbox }, EventType.NewMail); var connection = new StreamingSubscriptionConnection(service, new StreamingSubscription[] { subscription }, 30); connection.OnNotificationEvent += Connection_OnNotificationEvent; connection.Open(); //var response = service.BindToFolders(new FolderId[] { WellKnownFolderName.Inbox }, PropertySet.FirstClassProperties); //var results = service.FindItems(WellKnownFolderName.Inbox, new ItemView(int.MaxValue)); Console.ReadLine(); connection.Close(); }
public static void EnviarContaPorEmail(Contato contato) { string corpoMsg = string.Format("<h2>Contato - LojaVirtual</h2>" + "<b>Nome: </b> {0} <br />" + "<b>E-mail: </b> {1} <br />" + "<b>Texto: </b> {2} <br />" + "<br /> Email enviado automaticamente do site lojaVirtual", contato.Nome, contato.Email, contato.Texto); ExchangeService exchange = new ExchangeService(); WebCredentials webCredentials = new WebCredentials("*****@*****.**", "BGsword368"); exchange.Credentials = webCredentials; exchange.AutodiscoverUrl("*****@*****.**"); EmailMessage message = new EmailMessage(exchange); message.Subject = "Contato lojaVirtual teste -Email: " + contato.Email; //Mensagem Assunto message.Body = corpoMsg; // Corpo do Email message.ToRecipients.Add(new EmailAddress("*****@*****.**")); // Para quem? message.ToRecipients.Add(new EmailAddress("*****@*****.**")); // Para quem? message.SendAndSaveCopy(); //enviar mensagem /* * SMTP -> Servidor que vai enviar a mensagem. */ /* * SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587); * smtp.UseDefaultCredentials = false; * smtp.Credentials = new NetworkCredential("*****@*****.**", "overload863"); * smtp.EnableSsl = true; * string corpoMsg = string.Format("<h2>Contato - LojaVirtual</h2>" + * "<b>Nome: </b> {0} <br />" + * "<b>E-mail: </b> {1} <br />" + * "<b>Texto: </b> {2} <br />" + * "<br /> Email enviado automaticamente do site lojaVirtual", * contato.Nome, * contato.Email, * contato.Texto); */ /* * MailMenssage -> Construir a Mensagem a ser enviada. */ /* * MailMessage mensagem = new MailMessage(); * * mensagem.From = new MailAddress("*****@*****.**"); //Mensagem De * mensagem.To.Add("*****@*****.**");// Mensagem Para quem? * mensagem.To.Add("*****@*****.**");// Mensagem Para quem? * mensagem.Subject = "Contato lojaVirtual teste - Email: " + contato.Email; //Mensagem Assunto * mensagem.Body = corpoMsg; // Corpo do Email * mensagem.IsBodyHtml = true; //Para habilitar HTML na mensagem * * //enviar mensagem via smtp * smtp.Send(mensagem); * */ }
public Emailer() { this._exchange = new ExchangeService(ExchangeVersion.Exchange2007_SP1); WebCredentials credentials = new WebCredentials("inventoryalerts", "!23seti", "sskep.com"); this._exchange.Credentials = credentials; this._exchange.Url = new Uri(@"https://email.seoulsemicon.com/EWS/Exchange.asmx"); }
public ExchangeWebServices(string username, string password, string domain) { WebCredentials credentials = new WebCredentials(username, password, domain); ExService = new ExchangeService(ExchangeVersion.Exchange2013); ExService.Url = _uri; ExService.Credentials = credentials; }
public ExDialog(ResourceManager rm, string user, string pass, string serv, string email, string dID, string dType) { //user = user.Replace("\\", ""); cred = new WebCredentials(user, pass); mail = email; server = serv; username = user; _rm = rm; }
public Emailer(ILoggerFactory loggerFactory) { this._logger = loggerFactory.CreateLogger <Emailer>(); this._logger.LogInformation("Emailer Initialized"); this._exchange = new ExchangeService(ExchangeVersion.Exchange2007_SP1); WebCredentials credentials = new WebCredentials("inventoryalerts", "!23seti", "sskep.com"); this._exchange.Credentials = credentials; this._exchange.Url = new Uri(@"https://email.seoulsemicon.com/EWS/Exchange.asmx"); }
public EmailService(FacilityContext context) { this._context = context; this._exchange = new ExchangeService(ExchangeVersion.Exchange2007_SP1); WebCredentials credentials = new WebCredentials("facilityalerts", "Facility!1sskv", "sskep.com"); this._exchange.Credentials = credentials; this._exchange.Url = new Uri(@"https://email.seoulsemicon.com/EWS/Exchange.asmx"); this.GetRecipients(); }
public static async Task <int> Main(string[] args) { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); WebCredentials credentials = new WebCredentials("facilityalerts", "Facility!1sskv", "sskep.com"); service.Credentials = credentials; service.Url = new Uri(@"https://email.seoulsemicon.com/EWS/Exchange.asmx"); EmailMessage message = new EmailMessage(service); message.ToRecipients.Add("*****@*****.**"); message.Subject = "Inventory Stock Alert"; MessageBody body = new MessageBody(); body.Text = "Everything is broken!"; message.Body = body; await message.SendAndSaveCopy().ContinueWith(ret => Console.WriteLine("Done!")); Console.ReadKey(); return(1); //var connection = new HubConnectionBuilder() // .WithUrl("http://localhost:5000/hubs/monitor") // .Build(); //connection.On<string>(Strings.Events.ReadingSent, (data) => { // Console.WriteLine(data); //}); //// Loop is here to wait until the server is running //while (true) { // try { // await connection.StartAsync(); // break; // } catch { // await Task.Delay(1000); // } //} //Console.WriteLine("Client One listening. Hit Ctrl-C to quit."); //Console.ReadLine(); //var host = new HostBuilder() // .ConfigureLogging(logging => { // logging.AddConsole(); // }) // .ConfigureServices((services) => { // services.AddHostedService<MonitorHubClient>(); // services.AddHostedService<GeneratorHubClient>(); // }) // .Build(); //await host.RunAsync(); }
void ProcessBenchmark(object e) { ExchangeCredentials cred = new WebCredentials(textBoxUsername.Text, textBoxPassword.Text); string mailbox = textBoxMailbox.Text; if (String.IsNullOrEmpty(mailbox)) { mailbox = textBoxUsername.Text; } if (radioButtonOffice365.Checked) { _benchmark = new ClassBenchmark(mailbox, cred, _stats, _logger, "https://outlook.office365.com/EWS/Exchange.asmx"); } else if (radioButtonCustomUrl.Checked) { _benchmark = new ClassBenchmark(mailbox, cred, _stats, _logger, textBoxCustomEWSUrl.Text); ClassBenchmark.IgnoreSSLErrors = true; } else { _benchmark = new ClassBenchmark(mailbox, cred, _stats, _logger); } _benchmark.MaxThreads = (int)numericUpDownThreads.Value; _benchmark.SetTraceFile("trace.log"); if (checkBoxImpersonate.Checked) { _benchmark.Impersonate(textBoxMailbox.Text); } _benchmark.MaxItems = (int)numericUpDownMaxItems.Value; if (checkBoxRetrieveAllItems.Checked) { _benchmark.MaxItems = -1; } _benchmark.TestRuns = (int)numericUpDownTestRepeats.Value; _benchmark.RunBenchmark(); Action action = new Action(() => { buttonStart.Enabled = true; buttonStop.Enabled = false; }); if (buttonStart.InvokeRequired) { buttonStart.Invoke(action); } else { action(); } }
/// <summary> /// ExchangeMailClient /// </summary> /// <param name="clientConfig"></param> public ExchangeMailClient(IBasicAuthMailClientConfig clientConfig) { _clientConfig = clientConfig ?? throw new DocSasCorpMailException("clientConfig is required"); if (clientConfig.BasicAuthRequestInfo == null) { throw new DocSasCorpMailException("BasicAuthRequestInfo is required"); } else if (clientConfig.HostClientRequestInfo == null) { throw new DocSasCorpMailException("HostClientRequestInfo is required"); } _webCrendential = new WebCredentials(_clientConfig.BasicAuthRequestInfo.Username, _clientConfig.BasicAuthRequestInfo.Password); }
public Collection <ScopeProject> GetScopes() { Collection <ScopeProject> scopes = new Collection <ScopeProject>(); string relativeUri = "/scopes"; WebCredentials cred = new WebCredentials(); try { WebHttpClient webHttpClient = new WebHttpClient(adapterServiceUri, cred.GetNetworkCredential(), _proxyCredentials.GetWebProxy()); scopes = webHttpClient.Get <Collection <ScopeProject> >(relativeUri, true); } catch (Exception ex) { } return(scopes); }
public static string Update(string baseUri, string sparql, WebCredentials targetCredentials, WebProxyCredentials proxyCredentials) { try { string message = String.Empty; string relativeUri = "?update=" + HttpUtility.UrlEncode(sparql); WebHttpClient webClient = new WebHttpClient(baseUri, targetCredentials.GetNetworkCredential(), proxyCredentials.GetWebProxy()); message = webClient.GetMessage(relativeUri); return(message); } catch (Exception exception) { _logger.Error("Error in Update: " + exception); throw exception; } }
/// <summary> /// Get a NetworkCredential object from the ExchangeService /// object. In some cases this may not be a straight forward conversion. /// </summary> /// <returns>NetworkCredential retrieved</returns> public static NetworkCredential GetNetworkCredential(this ExchangeService service) { if (service.Credentials == null) { return(null); } WebCredentials webCreds = (WebCredentials)service.Credentials; if (!(webCreds.Credentials is NetworkCredential)) { throw new ApplicationException("Unexpected Credential type in ExchangeService.Credentials."); } return((NetworkCredential)webCreds.Credentials); }
public Mailboxes(WebCredentials AutodiscoverCredentials, ClassLogger Logger, ITraceListener TraceListener = null) { _logger = Logger; _mailboxes = new Dictionary <string, MailboxInfo>(); _autodiscover = new AutodiscoverService(ExchangeVersion.Exchange2013); // Minimum version we need is 2013 _autodiscover.RedirectionUrlValidationCallback = RedirectionCallback; if (TraceListener != null) { _autodiscover.TraceListener = TraceListener; _autodiscover.TraceFlags = TraceFlags.All; _autodiscover.TraceEnabled = true; } if (!(AutodiscoverCredentials == null)) { _autodiscover.Credentials = AutodiscoverCredentials; } }
public ExchangeProxy(ISearchPolicy policy, GroupId groupId) { Recorder.Trace(5L, TraceType.InfoTrace, new object[] { "ExchangeProxy.ctor GroupId:", groupId, "GroupType:", groupId.GroupType, "Uri:", groupId.Uri }); this.groupId = groupId; this.policy = policy; ExchangeCredentials credentials; if (this.groupId.GroupType == GroupType.CrossPremise) { credentials = new OAuthCredentials(OAuthCredentials.GetOAuthCredentialsForAppToken(this.policy.CallerInfo.OrganizationId, groupId.Domain)); } else { credentials = new WebCredentials(); } string text = string.Format("{0}&FOUT=true", policy.CallerInfo.UserAgent); this.InitializeExchangeProxy(credentials, groupId.Uri, (long)groupId.ServerVersion); this.exchangeService.HttpHeaders[CertificateValidationManager.ComponentIdHeaderName] = typeof(IEwsClient).FullName; this.exchangeService.ClientRequestId = this.policy.CallerInfo.QueryCorrelationId.ToString(); this.exchangeService.Timeout = (int)TimeSpan.FromMinutes(this.policy.ThrottlingSettings.DiscoverySearchTimeoutPeriod).TotalMilliseconds; if (this.groupId.GroupType == GroupType.CrossPremise) { this.exchangeService.UserAgent = text; this.exchangeService.ManagementRoles = new ManagementRoles(null, ExchangeProxy.mailboxSearchApplicationRole); return; } this.exchangeService.UserAgent = WellKnownUserAgent.GetEwsNegoAuthUserAgent(string.Format("{0}-{1}", ExchangeProxy.crossServerUserAgent, text)); if (this.policy.CallerInfo.CommonAccessToken != null && !this.policy.CallerInfo.IsOpenAsAdmin) { this.exchangeService.HttpHeaders["X-CommonAccessToken"] = this.policy.CallerInfo.CommonAccessToken.Serialize(); if (this.policy.CallerInfo.UserRoles != null || this.policy.CallerInfo.ApplicationRoles != null) { this.exchangeService.ManagementRoles = new ManagementRoles(this.policy.CallerInfo.UserRoles, this.policy.CallerInfo.ApplicationRoles); } } }
void GetIRTFolderExecute() { try { // Configure open file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "Web.config"; // Default file name dlg.DefaultExt = ".config"; // Default file extension dlg.Filter = "Web Configuration (.config)|*.config"; // Filter files by extension dlg.Title = "Select the file Web.config in the iRINGTools Services folder"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { // Get folder path _registeryParams.ServicesWebConfig = dlg.FileName; OnPropertyChanged("ServicesWebConfig"); XDocument adminConfig = XDocument.Load(_registeryParams.ServicesWebConfig); string encryptedCredentials = adminConfig.GetSetting("RegistryCredentialToken"); WebCredentials credentials = new WebCredentials(encryptedCredentials); if (credentials.isEncrypted) { credentials.Decrypt(); } this.Username = credentials.domain + @"\" + credentials.userName; OnPropertyChanged("Username"); this.Password = credentials.password; OnPropertyChanged("Password"); // this.ProxyHost = adminConfig.GetSetting("ProxyHost"); OnPropertyChanged("ProxyHost"); // this.ProxyPort = adminConfig.GetSetting("ProxyPort"); OnPropertyChanged("ProxyPort"); } } catch (Exception exc) { MessageBox.Show("Error occurred while getting folder. " + exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
public static SPARQLResults Query(string baseUri, string sparql, WebCredentials targetCredentials, WebProxyCredentials proxyCredentials) { try { SPARQLResults sparqlResults = null; string relativeUri = "?query=" + HttpUtility.UrlEncode(sparql); WebHttpClient webClient = new WebHttpClient(baseUri, targetCredentials.GetNetworkCredential(), proxyCredentials.GetWebProxy()); sparqlResults = webClient.Get <SPARQLResults>(relativeUri, false); return(sparqlResults); } catch (Exception exception) { _logger.Error("Error in Query: " + exception); throw exception; } }
static WebRequest CreateWebRequest(string url) { WebRequest request = WebRequest.Create(url); if (!string.IsNullOrEmpty(_proxyHost)) { WebCredentials proxyCreds = new WebCredentials(_proxyCredentialToken); if (proxyCreds.isEncrypted) { proxyCreds.Decrypt(); } WebProxy proxy = new WebProxy(_proxyHost, _proxyPort); proxy.Credentials = proxyCreds.GetNetworkCredential(); request.Proxy = proxy; } return(request); }
/// <summary> /// Rechaza un Appointment /// </summary> /// <param name="userId"></param> /// <param name="password"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="id"></param> /// <param name="message"></param> /// <returns></returns> public string DeclineAppointment(string userId, string password, string id, string mess) { try { Console.WriteLine("Init"); service = new ExchangeService(ExchangeVersion.Exchange2013_SP1); credentials = new WebCredentials(userId, password); service.Credentials = credentials; service.Url = new Uri("https://mail.migesa.com.mx/ews/exchange.asmx"); DateTime startDate = DateTime.Now.AddMonths(-6); DateTime endDate = DateTime.Now.AddMonths(6); // Initialize the calendar folder object with only the folder ID. CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()); // Set the start and end time and number of appointments to retrieve. CalendarView cView = new CalendarView(startDate, endDate); // Limit the properties returned to the appointment's subject, start time, and end time. cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End); // Retrieve a collection of appointments by using the calendar view. FindItemsResults <Microsoft.Exchange.WebServices.Data.Appointment> appointments = calendar.FindAppointments(cView); negocio.Entidades.Appointment appoint = null; foreach (Microsoft.Exchange.WebServices.Data.Appointment a in appointments) { a.Load(); if (a.Id.ToString() == id) { a.Decline(true); } } return(""); } catch (Exception ex) { exchangeInitialized = false; return(ex.Message); } }
private WebCredentials GetWebCredentials(bool bDefaultCredentials, string sUser, string sPassword, string sDomain) { WebCredentials credentials = null; if (bDefaultCredentials == true) { credentials = new WebCredentials(); } else { if (txtDomain.Text.Trim().Length != 0) { credentials = new WebCredentials(sUser, sPassword, sDomain); } else { credentials = new WebCredentials(sUser, sPassword); } } return(credentials); }
public async Task <bool> ConnectAsync(string email, string password) { return(await System.Threading.Tasks.Task.Run(() => { IsConnected = false; _email = email; service = new ExchangeService(ExchangeVersion.Exchange2013_SP1); service.TraceEnabled = true; service.TraceFlags = TraceFlags.All; service.Url = new Uri("https://webmail.maersk.net"); ExchangeCredentials credentials = new WebCredentials(email, password); service.Credentials = credentials; service.AutodiscoverUrl(email, RedirectionUrlValidationCallback); service.KeepAlive = true; if (service != null) { IsConnected = true; } return IsConnected; })); }
static void Main(string[] args) { string userName = String.Empty; string password = String.Empty; string domain = String.Empty; if (args.Length >= 2) { userName = args[0]; password = args[1]; if (args.Length > 2) { domain = args[2]; } WebCredentials credentials = new WebCredentials { userName = userName, password = password, domain = domain }; credentials.Encrypt(); Console.WriteLine(credentials.encryptedToken); } else if (args.Length >= 1) { string value = args[0]; string encryptedValue = Encryption.EncryptString(value); Console.WriteLine(encryptedValue); } else { Console.WriteLine(HELP_MESSAGE); } }
void UpdateCommandExecute() { try { bool isValid = true; if (_registeryParams.ServicesWebConfig == "") { isValid = false; OnPropertyChanged("ServicesWebConfig"); } if (!isValid) { MessageBox.Show("One or more parameters invalid.", "Validation Failed", MessageBoxButton.OK, MessageBoxImage.Information); return; } XDocument adminConfig = XDocument.Load(_registeryParams.ServicesWebConfig); if (String.IsNullOrEmpty(_registeryParams.ProxyHost)) { adminConfig.RemoveSetting("RegistryCredentialToken"); // adminConfig.RemoveSetting("ProxyHost"); // adminConfig.RemoveSetting("ProxyPort"); } else { if (!String.IsNullOrEmpty(_registeryParams.Username)) { WebCredentials credentials = new WebCredentials { userName = _registeryParams.Username, password = _registeryParams.Password, domain = _registeryParams.Domain }; credentials.Encrypt(); adminConfig.UpdateSetting("RegistryCredentialToken", credentials.encryptedToken); } else { adminConfig.RemoveSetting("MCraftFileServer"); } string proxyPort = _registeryParams.ProxyPort; if (String.IsNullOrEmpty(proxyPort)) { proxyPort = "8080"; } _registeryParams.ProxyPort = proxyPort; OnPropertyChanged("ProxyPort"); // adminConfig.UpdateSetting("ProxyHost", _registeryParams.ProxyHost); // adminConfig.UpdateSetting("ProxyPort", proxyPort); } adminConfig.Save(_registeryParams.ServicesWebConfig); MessageBox.Show("Update complete.", "Update Complete", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception exc) { MessageBox.Show("Error occurred while getting updating proxy configuration. " + exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } // sample code //bool isupdated = true; //if (_registeryParams.iRingToolsFolder!="") //{ // isupdated = false; //} //if (isupdated) //{ // BackgroundBrush = new SolidColorBrush(Colors.Green); //} //else //{ // BackgroundBrush = new SolidColorBrush(Colors.White); //} }
private void DoAutodiscoverDirectlyAgainstAutiodiscoverService() { bool bEnableInMemoryTracing = true; this.Cursor = Cursors.WaitCursor; _Certs = string.Empty; _Redirects = string.Empty; WebCredentials credentials = null; InMemoryListener oIML = null; string sResults = string.Empty; // Clear results this.txtCerts.Text = ""; this.txtTracing.Text = ""; this.txtResults.Text = ""; this.txtCerts.Update(); this.txtTracing.Update(); this.txtResults.Update(); _Version = GetExchangeVersion(cmboExchangeVersion.Text.Trim()); EwsRedirectLoggingCallbackHelper oEwsRedirectLoggingCallbackHelper = new EwsRedirectLoggingCallbackHelper(); EwsCertificateLoggingCallbackHelper oEwsCertificateLoggingCallbackHelper = new EwsCertificateLoggingCallbackHelper(); // EwsLoggingCallbackHelper oAutodiscoveryCallbackHelper = new EwsLoggingCallbackHelper(); AutodiscoverService service = new AutodiscoverService(_Version); credentials = GetWebCredentials( this.chkDefaultWindowsCredentials.Checked, txtUser.Text.Trim(), txtPassword.Text.Trim(), txtDomain.Text.Trim() ); service.Credentials = credentials; // Prevent the AutodiscoverService from looking in the local Active Directory for the Exchange Web Services Services SCP. service.EnableScpLookup = this.chkEnableScpLookup.Checked; service.PreAuthenticate = this.chkPreAuthenticate.Checked; if (bEnableInMemoryTracing == true) { oIML = new InMemoryListener(); // Enable for EWS tracing service.TraceFlags = TraceFlags.All; // Enable for EWS tracing service.TraceEnabled = true; // Enable for EWS tracing service.TraceListener = oIML; // Enable for EWS tracing } service.UserAgent = "AutodiscoverCheckerGetUserSettings"; ServicePointManager.ServerCertificateValidationCallback = oEwsCertificateLoggingCallbackHelper.CertificateValidationCallBack; // Handle and Log redirects service.RedirectionUrlValidationCallback = oEwsRedirectLoggingCallbackHelper.RedirectionUrlValidationCallbackAllowAnything; oEwsRedirectLoggingCallbackHelper.UseCredentials = this.GetWebWebRequestCredentials( this.chkDefaultWindowsCredentials.Checked, txtUser.Text.Trim(), txtPassword.Text.Trim(), txtDomain.Text.Trim() ); // The following is used in the work-arouind for a redirect which involves an SMTP address change - it needs to be st to what you autodiscovering on. oEwsRedirectLoggingCallbackHelper.AutodiscoveringAddress = txtTargetMailbox.Text.Trim(); oEwsRedirectLoggingCallbackHelper._DoAddressRedirectWorkAround = chkWorkAroundAddressRedirectIssue.Checked; // Do Autodiscover: sResults = AutodiscoverGetUserSettings(ref service, txtTargetMailbox.Text.Trim()); if (oEwsRedirectLoggingCallbackHelper._AddressRedirection == true) { // Lets do Autodiscover again - but this time use the alternative address. string AutodiscoveringAddress = oEwsRedirectLoggingCallbackHelper._RedirectEmailAddress; oEwsRedirectLoggingCallbackHelper.ResetRedirects(); oEwsRedirectLoggingCallbackHelper.AutodiscoveringAddress = AutodiscoveringAddress; //oEwsRedirectLoggingCallbackHelper.AutodiscoveringAddress = oEwsRedirectLoggingCallbackHelper._RedirectEmailAddress; sResults += "\r\n"; sResults += "Autodiscover failed but a redirect address was found. So, do Autodiscover again with the new address.\r\n"; sResults += "Now doing Autodiscover process with: " + AutodiscoveringAddress + "\r\n\r\n"; sResults += AutodiscoverGetUserSettings(ref service, AutodiscoveringAddress); } txtCerts.Text = oEwsCertificateLoggingCallbackHelper._Certificates; txtTracing.Text += "\r\n[*****============================[Redirects]=====================================*****]\r\n\r\n"; txtTracing.Text += oEwsRedirectLoggingCallbackHelper._RedirectionUrls; if (bEnableInMemoryTracing == true) { txtTracing.Text += "\r\n[*****============================[Trace Log]=====================================*****]\r\n\r\n"; txtTracing.Text += oIML.LogText; } txtResults.Text = sResults; service.TraceListener = null; oIML = null; // Enable for EWS tracing service.RedirectionUrlValidationCallback = null; ServicePointManager.ServerCertificateValidationCallback = null; oEwsCertificateLoggingCallbackHelper = null; oEwsRedirectLoggingCallbackHelper = null; this.Cursor = Cursors.Default; }
public static void PostQueryAsMultipartMessage(string baseUri, string sparql, WebCredentials targetCredentials, WebProxyCredentials proxyCredentials) { try { string result = string.Empty; MultiPartMessage requestMessage = new MultiPartMessage { name = "update", type = MultipartMessageType.FormData, message = sparql, }; List <MultiPartMessage> requestMessages = new List <MultiPartMessage> { requestMessage }; WebHttpClient webClient = new WebHttpClient(baseUri, targetCredentials.GetNetworkCredential(), proxyCredentials.GetWebProxy()); string response = String.Empty; webClient.PostMultipartMessage("", requestMessages, ref response); } catch (Exception exception) { _logger.Error("Error in PostQueryAsMultipartMessage: " + exception); throw exception; } }
private void btnLogOut_Click(object sender, EventArgs e) { WebCredentials.DeleteAllCredentials(); RefreshLogOutButton(); }
public MailService(string courtLevel, IConfiguration configuration, ILogger logger) { _configuration = configuration; _logger = logger; _emailCredentials = SetExchangeCredentials(courtLevel); }
private void RefreshLogOutButton() { btnLogOut.Enabled = WebCredentials.AnyCredentialsExist(); }