private Boolean IsValidMailMessage(MailMessage message)
{
if (message == null)
return false;
if (message.From == null)
return false;
if (!message.From.Address.Contains('@'))
return false;
if (message.To == null)
return false;
if (message.To.Count == 0)
return false;
foreach (var item in message.To)
{
if (!item.Address.Contains('@'))
return false;
}
if (message.Body == null)
return false;
if (String.IsNullOrWhiteSpace(message.Body))
return false;
return true;
}
private Boolean IsValidMailMessage(MailMessage message)
{
Boolean isValid = true;
if (message != null)
{
if (message.From != null)
{
if (!message.From.Address.Contains('@'))
isValid = false;
}
else
{
isValid = false;
}
if (message.To != null)
{
if (message.To.Count == 0)
isValid = false;
foreach (var item in message.To)
{
if (!item.Address.Contains('@'))
isValid = false;
}
}
else
{
isValid = false;
}
if (message.Body != null)
{
if (String.IsNullOrWhiteSpace(message.Body))
isValid = false;
}
else
{
isValid = false;
}
}
else
{
isValid = false;
}
return isValid;
}