hi I'm trying to use this code that i found to send an email message using c# application.
i have an iis service running on my computer and the smtp server is configured as my providers smtp server.

the problem is that when i try to send mail i get an error message:
"the specified string is not in the form required for an e-mail address"

i swear to god that i insert a valid mail address.

my code is:

MailMessage message = new MailMessage(to, from, subject, mess);               
                SmtpClient client = new SmtpClient("mail.bezeqint.net");
                client.UseDefaultCredentials = true;
                client.Send(message);

                return "Message sent to " + to + " at " + DateTime.Now.ToString() + ".";

help please.

your 'from' is a valid email address as well not just a name?

you're right the from name was not valid.

but now it's sending the message but it does not arrive.

any ideas ?

Are the from/to addresses local to the mail server, eg, you arent trying to relay?

the mails are not local.
i guess i tried many options and i dont know which one one is right.
i tried to configure the iis smtp server to my isp and i entered my password, when i tried to send it showed an error that access was denied.
i tried to reset all settings and defined the relay on 127.0.0.1 (local host). nothing seems to work.
is there any way to send emails with the iis default smtp server ?

Look I've experience about that, I never ever use SMTP to send emails because I am sure the destination would be the JUNK! I use CDO (Microsoft CDO for Windows 2000 library) instead.

ok i looked for Microsoft CDO for Windows 2000 library and i found some code that should do the job:

CDO.Message oMsg = new CDO.Message();
                CDO.IConfiguration iConfg;

                iConfg = oMsg.Configuration;

                ADODB.Fields oFields;
                oFields = iConfg.Fields;

                // Set configuration.
                ADODB.Field oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"]

oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
                oField.Value = 1; 

oMsg.Subject = "Test";
oMsg.From = from;
                oMsg.To = to;
oMsg.Send();

is there any other configuration i should do ?
cause i ran the code (doesn't seem to do anything).

the mails are not local.
i guess i tried many options and i dont know which one one is right.
i tried to configure the iis smtp server to my isp and i entered my password, when i tried to send it showed an error that access was denied.
i tried to reset all settings and defined the relay on 127.0.0.1 (local host). nothing seems to work.
is there any way to send emails with the iis default smtp server ?

Then it sounds quite simply as the servers not prepared to hand it on because neither the sender or receiver are domains it controls and its not an open realy.

Which is normal. Most servers these days are configured that way to reduce spam.

No way man ... you can do this

mail.Priority = MailPriority.High;

or

mail.Priority = MailPriority.Normal;

works like a bombbbbbbb

try to check ur smtp server credentials :

client.credential = new NetworkCredential("mail.bezeqint.net","Put Ur Passwords");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.