Based on your code it looks like you might want to check if your "from" address is null or empty as well. An easy way to do this is:
if(string.IsNullOrEmpty(to) || string.IsNullOrEmpty(from))
{
// one of your addresses is empty so don't send it
}
else
{
// go ahead and send it
}