tags:

views:

238

answers:

3

Well i got a page that sends emails and everything runs fine in the developer web server but when i publish to a IIS Server i get a FormatException when i try to send the mail.... ex.Message = "the specified string is not in the form required for an e-mail address."

the email is in this sample [email protected]

Im using the "SmtpClient" and the "MailMessage" classes to send mails..

And the server runs windows server 2003

Edit: Im using same smtp settings on the Dev Webserver as im doing in IIS.

+1  A: 

Check that you've enabled local email relaying for the SMTP service on your Windows Server 2003 box. By 'local' I mean that applications on your local machine can use the SMTP service to relay emails - but you almost certainly don't want to allow external connections to do the same.

David Gardiner
how do i check that?
Petoj
Assuming of course that you are using a local SMTP service..Open up the IIS MMC and go to the SMTP service.Edit the properties to allow local connections (eg. 127.0.0.1)
David Gardiner
+1  A: 

Hi, Make sure you don't have any invisible whitespace around your email address. For example, if you are getting the email from a database, or input control, try trimming it, like:

mail.To.Add( New MailAddress( txtEmailAddress.Text.Trim() ) )

Cheers! Dave

dave wanta
Good idear but didnt help... any way it works in my web developer server but not on one of our IIS Servers...
Petoj
A: 

If any one gets this problem the solution is don't use the empty constructor of MailMessage!!!!!

Petoj