How to put email in value for Switch

  • Автор темы Автор темы yomomma
  • Дата начала Дата начала

yomomma

Пользователь
Регистрация
17.02.2013
Сообщения
53
Реакции
2
Баллы
8
How do I get the value "xyz@gmail.com" to be read in Switch as an email with "gmail.com" in the 0 value?
 

Yes, I am having difficulty with getting it to identify specific emails.

Hi. If I understood you right then first you have to do regex and get email service from your email. When you get gmail.com in separate variable then you can set gmail.com in 0 in switch and set this new variable to check against.

If I have 2 different emails (i.e. gmail and outlook) then I have to create variables for both?
 
c# action?
Код:
Развернуть Свернуть Копировать
string email = project.Variables["email"].Value.Substring(project.Variables["email"].Value.IndexOf('@') + 1);
//uncomment for debugging
//return email;
switch (email)
{
    case "gmail.com":
        return "gmail";
        break;
    case "outlook.com":
        return "outlook";
        break;
    default:
           return "bad email";
}
 
Thanks for the idea and code.
 
Yes, I am having difficulty with getting it to identify specific emails.



If I have 2 different emails (i.e. gmail and outlook) then I have to create variables for both?

No no need for two variables. One variable emailService and thats it.

W0VQsP5.png
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)