Most of the smarter stmp servers dont allow relays, instead they expect
userid and password for sending particular email. Unfortunately .Net Mail
namespace doesn't provide any of such funcationality, so how we are going to
send emails in case where the stmp requires authentication. The answer lies
in the new property of Mail Message namely 'Fields' which you can find in
Framwork 1.1. You can use fields property of mailmessage like this to provide
credentials
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here
"Coder" wrote:
If outgoing server requires authentication,
How can I use smtpmail object in c# ?
I use a windows 2003 server hosting packet somewhere...
string from = "re******@xxx.com";
string to = UserEMail;
string subject = "Subject";
string body = "Test";
SmtpMail.SmtpServer = "smtp.xxx.com";
SmtpMail.Send(from, to, subject, body);