private void lnkDisplayCurrentInfo_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { MainForm.DefInstance.Cursor = Cursors.WaitCursor; rtbDisplay.Clear(); Application.DoEvents(); AddToRtbLocal("Looking up current outbound email settings\r\n", StyleType.bodyChocolate); try { string smtpCurrent = SPEmail.GetCurrentSMTPSettings(); if (string.IsNullOrEmpty(smtpCurrent)) { AddToRtbLocal("Current SMTP Server has not been set. (Outbound Email is not set up.)\r\n", StyleType.bodyBlueBold); } else { AddToRtbLocal("Current SMTP Server for outbound email: ", StyleType.bodyBlack); AddToRtbLocal(smtpCurrent + "\r\n", StyleType.bodyBlue); } } catch (Exception ex) { AddToRtbLocal("Error: " + ex.Message, StyleType.bodyRed); } finally { MainForm.DefInstance.Cursor = Cursors.Default; } }
private void lnkBrowseToOutboundEmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { string emailConfigurationURL = SPEmail.GetMailConfiugrationURL(); Util.OpenURLinDefaultBrowser(emailConfigurationURL, rtbDisplay); } catch (Exception ex) { AddToRtbLocal(ex.Message, StyleType.bodyRed); } }
/// <summary> /// Sends a test email. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSend_Click(object sender, EventArgs e) { try { rtbDisplay.Clear(); string smtp = txtSMTP.Text.Trim(); AddToRtbLocal("Sending test message to ", StyleType.bodyChocolate); AddToRtbLocal(txtFromEmail.Text, StyleType.bodyBlue); AddToRtbLocal(" via SMTP server ", StyleType.bodyChocolate); AddToRtbLocal(smtp + "\r\n", StyleType.bodyBlue); SPEmail.SendEmail(smtp, txtFromEmail.Text, txtFromEmail.Text, _subject, populateBody(smtp)); AddToRtbLocal("\r\nDONE. Successfully sent test email to SMTP server.\r\n", StyleType.bodySeaGreen); } catch (Exception ex) { AddToRtbLocal("Error while trying to sending mail: ", StyleType.bodyBlack); AddToRtbLocal(ex.Message + "\r\n\r\n", StyleType.bodyRed); } }