Mail Server Settings

Mail Server Settings

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings
  • Sitecore.Context
  • Sitecore.Data.Items.Item

C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

string mailServer = Sitecore.Configuration.Settings.MailServer;
string mailServerPassword = Sitecore.Configuration.Settings.MailServerPassword;
string mailServerPort = Sitecore.Configuration.Settings.MailServerPort.ToString();
string mailServerUserName = Sitecore.Configuration.Settings.MailServerUserName;

output.Write("{0}&#58;&#160;{1}", "Mail Server", "<b>" + mailServer + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Mail Server Password", "<b>" + mailServerPassword + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Mail Server Port", "<b>" + mailServerPort + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Mail Server User Name", "<b>" + mailServerUserName + "</b>");
output.RenderEndTag(); //Div


C# Web Control Real-time Output

Item: Mail Server Settings

Mail Server: smtp.theinsidecorner.com
Mail Server Password: ga7dx-PCs
Mail Server Port: 25
Mail Server User Name: cwnelson@theinsidecorner.com