Hi Team,
I have tried a Email Validation using BADI : #ValidateReceipientEmail. Have tried to concatenate all the email in TO, CC & BCC. Below is the code snippet for your reference -
/*
Add your SAP Business ByDesign scripting language implementation for:
Enhancement Option: ValidateRecipientEmail
Operation: VALIDATE_RECIPIENT_EMAIL
Script file signature
----------------------------
Parameter: InputData of type RecipientEmailIn
Returns: ValidateRecipientEmailOut
Author: Subhankar Chakraborty
*/
import AP.CRM.Global;
import AP.Common.Global;
import AP.Common.GDT;
import AP.PlatinumEngineering;
var result : ValidateRecipientEmailOut;
var validEmail : Indicator;
var inputEmail : RecipientEmailIn;
var Email : EmailURI;
var ToEmail = InputData.TOEmailAddress.content;
var CCEmail = InputData.CCEmailAddress.content;
var BCCEmail = InputData.BCCEmailAddress.content;
var resultData : collectionof DataType::LANGUAGEINDEPENDENT_EXTENDED_Text;
//Concat sting with the split variable at the end of the string
var Comma = ";";
var con;
var len;
//For Checking To Email
if (!ToEmail.IsInitial() || !CCEmail.IsInitial() || !BCCEmail.IsInitial())
{
// Having all the email id in a variable
con = ToEmail + Comma + CCEmail + Comma + BCCEmail + Comma;
}
//find the length
len = con.Length();
//variable for holding the position of the split variable in the string
var split_pos;
//variable for holding the loop value
var loop_var = 0;
// Variable for holding the sting position of the Sting
var string_pos = 0;
//Split based on Blank
var loc_split = Comma;
//local variable got holding the length of the sub string
var sub_str_len;
//local variable for holding sub string
var sub_string;
while (len >= loop_var)
{
if (len <= string_pos)
{
break;
}
split_pos = con.Find(loc_split, string_pos);
if (loop_var > 0)
{
sub_str_len = split_pos - string_pos;
}
else
{
sub_str_len = split_pos;
}
sub_string = con.Substring(string_pos, sub_str_len).Trim();
resultData.Add(sub_string);
string_pos = split_pos + 1;
loop_var = loop_var + sub_str_len;
}
var HaveMultipleEmail = resultData.Where(n => n.Length() > 0);
foreach (var checkAllEmail in HaveMultipleEmail)
{
// Mail.CheckEmailAddress -> This is from Platenium Engineering for validating the e-mail
result.IsEmailValid = Mail.CheckEmailAddress(checkAllEmail);
if(result.IsEmailValid == false)
{
result.IsEmailValid = false;
}
else
{
result.IsEmailValid = true;
}
}
return result;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.