config file :
Where have you placed these elements inside your web.config? They should look like this:
But based on the exception you're getting it sounds like the config is working but your message is improperly formatted. What does your MailMessage look like? What are you passing as your From, Email, Subject and Body?