Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ReRoute Emails
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { private static bool overwriteEmailAddressWithTestEmailAddress = false; //private static bool overwriteEmailAddressWithTestEmailAddress = true; private static string TestEmailAddress = "cvoportal@gmail.com;buffskan@gmail.com;*@e.rainforestqa.com;*@outlookamusements.com"; private static string TestEmailDomains = "@example.com"; public static void Main(string[] args) { //Your code goes here Console.WriteLine("3. {0}", RouteEmail("someone@example.com")); Console.WriteLine("4. {0}", RouteEmail("tester@e.rainforestqa.com")); Console.WriteLine("5. {0}", RouteEmail("employee@outlookamusements.com")); } private static string RouteEmail(string emailAddress) { //make sure email address is not empty if (string.IsNullOrEmpty(emailAddress)) { throw new Exception("No Receipient Email Address Specified"); } else if (emailAddress.IndexOf("@") <= -1) { throw new Exception("Invalid Email Address"); } else { //check if we should forward to test email account. var emailAddressDomain = string.Concat("@", emailAddress.Split(new char[] { '@' })[1]); if (!overwriteEmailAddressWithTestEmailAddress) { //check if email contains domain that should be forwarded to test if (TestEmailDomains.Contains((emailAddressDomain.ToLower().Trim()))) { overwriteEmailAddressWithTestEmailAddress = true; } } //send to test email if in test mode or test domain matched if (overwriteEmailAddressWithTestEmailAddress) { //overwrite with test email if set var testEmailAddresses = TestEmailAddress.Trim().Replace(" ", "").Split(new char[] { ',', ';' }); //check an overwrite for real email and also check to allow test email domains e.g *@e.rainforestqa.com if (!testEmailAddresses.Contains(emailAddress) && !testEmailAddresses.Contains("*" + emailAddressDomain)) { emailAddress = testEmailAddresses[0]; } } } return emailAddress; } } }
run
|
edit
|
history
|
help
0
StudentSysInput
Digging Deeper
sample
C# program to Determine if Two Words Are Anagrams of Each Other
Few Programs that would help in interviews
test array with c#
Lesson 1.2 Part II
insertion sort
Selection sort
AKASH B AND HIS CODES\\