In your code you must eliminate the ! from the comparison... you are checking if the value is different from @ and showing a VALID message...
You can use...
CString m_sFrom;
GetdlgItemText(IDC_EDIT_FROM, m_sFrom);
if (m_sFrom.Find("@")!=-1)
{
AfxMessageBox("valid");
}
else
{
AfxMessageBox("Invalid");
}
You could do DDX which is easier to interact...
HTH...
PS: you should follow the advice from John... regex is the way to go... I've only followed your sample correcting the way you are checking the contents on the string and a couple of things more...