943,652 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 3399
  • C# RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 16th, 2009
0

error sending mail using system.net.mail

Expand Post »
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:

c# Syntax (Toggle Plain Text)
  1. MailMessage message = new MailMessage(to, from, subject, mess);
  2. SmtpClient client = new SmtpClient("mail.bezeqint.net");
  3. client.UseDefaultCredentials = true;
  4. client.Send(message);
  5.  
  6. return "Message sent to " + to + " at " + DateTime.Now.ToString() + ".";

help please.
Similar Threads
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

your 'from' is a valid email address as well not just a name?
Reputation Points: 155
Solved Threads: 41
Posting Whiz in Training
rapture is offline Offline
294 posts
since Jul 2007
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

you're right the from name was not valid.

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

any ideas ?
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

Are the from/to addresses local to the mail server, eg, you arent trying to relay?
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

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 ?
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

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

c# Syntax (Toggle Plain Text)
  1. CDO.Message oMsg = new CDO.Message();
  2. CDO.IConfiguration iConfg;
  3.  
  4. iConfg = oMsg.Configuration;
  5.  
  6. ADODB.Fields oFields;
  7. oFields = iConfg.Fields;
  8.  
  9. // Set configuration.
  10. ADODB.Field oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"]
  11.  
  12. oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
  13. oField.Value = 1;
  14.  
  15. oMsg.Subject = "Test";
  16. oMsg.From = from;
  17. oMsg.To = to;
  18. oMsg.Send();

is there any other configuration i should do ?
cause i ran the code (doesn't seem to do anything).
Reputation Points: 20
Solved Threads: 0
Junior Poster
emilio is offline Offline
162 posts
since Nov 2007
Jan 16th, 2009
0

Re: error sending mail using system.net.mail

Click to Expand / Collapse  Quote originally posted by emilio ...
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.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jan 18th, 2009
0

Re: error sending mail using system.net.mail

Reputation Points: 28
Solved Threads: 5
Light Poster
BlackSun is offline Offline
46 posts
since Feb 2008
Jan 19th, 2009
0

Re: error sending mail using system.net.mail

No way man ... you can do this

c# Syntax (Toggle Plain Text)
  1. mail.Priority = MailPriority.High;

or

c# Syntax (Toggle Plain Text)
  1. mail.Priority = MailPriority.Normal;

works like a bombbbbbbb
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Automatially move data
Next Thread in C# Forum Timeline: Scrollbars in windows application





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC