HELP: SMTP SmtpMail How do I set a username and password?

  • Thread starter Thread starter T.Archer
  • Start date Start date
T

T.Archer

The host a client wants to use requires authentication to relay messages.

How do I set the authentication (username/password) before using the
smtpmail.send(mailmessage) method?

Surely this must be a common thing to do. I have been utterly unable to
google an answer.

--Tony Archer
 
The mail functionality that the System.Web.Mail class represents doesn't
have authenticated SMTP mail capabilities. You'll need to find another
compoennt in order to send an SMTP server that requires authentication.
Tgere are lots of free ones out there though so that's not a big problem.
There's an open-source SMTP project at:
http://sourceforge.net/projects/opensmtp-net/ that may work nicely.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
Actually, I believe that there is a way, but you have to specify the headers
manually.

For an example, see;
http://www.paulsadowski.com/WSH/cdo.htm

'==This section provides the configuration information for the remote SMTP
server.

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =
cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") =
"youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
"yourpassword"


However, Mark's recommendation is best; there are a number of solid
..NET-specific email components out there with fantastic capabilities.
You'll probably be better off avoiding CDO.

/// M
 
Back
Top