public static DialogResult ShowDialog(ref Mailbox mbx) { GetMailboxNameDialog dialog = new GetMailboxNameDialog(); DialogResult res = dialog.ShowDialog(); if (res == DialogResult.OK) { mbx = new Mailbox(dialog.txtSMTP.Text); } return(res); }
/// <summary> /// Display the GetMailboxNameDialog to get the SMTP address and /// perform Autodiscover operation to get the EWS service URL. /// </summary> /// <param name="sender">The parameter is not used.</param> /// <param name="e">The parameter is not used.</param> private void BtnAutodiscover_Click(object sender, EventArgs e) { Mailbox mbx = null; // If the result isn't OK do nothing. if (GetMailboxNameDialog.ShowDialog(ref mbx) != DialogResult.OK) { return; } try { this.Cursor = Cursors.WaitCursor; ExchangeService tempService = new ExchangeService(ExchangeVersion.Exchange2010); tempService.TraceEnabled = true; tempService.TraceEnablePrettyPrinting = true; tempService.TraceListener = new EWSEditor.Logging.EwsTraceListener(); if (GlobalSettings.AllowAutodiscoverRedirect) { tempService.AutodiscoverUrl( mbx.Address, delegate(string url) { return(true); }); } else { tempService.AutodiscoverUrl(mbx.Address); } AutodiscoverEmailText.Text = mbx.Address; ExchangeServiceURLText.Text = tempService.Url.ToString(); } finally { this.Cursor = Cursors.Default; } }