How do I logon to SMTP server using SmtpMail .NET class?

  • Thread starter Thread starter Ken Varn
  • Start date Start date
K

Ken Varn

I want to use the SmtpMail .NET class to send e-mail. The SMTP e-mail
server that I need to connect with requires a logon and password to allow
send to occur. Is there anyway that I can perform the logon and send the
e-mail to the SMTP server using the SmtpMail class?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
Hi Ken

It doesn't appear that the built in SmtpMail class will do what you need.
It appears that it relys on a smarthost server that will blindly relay for
you without authentication. I'm not sure if this is a solution for you but
you could install the smtp service on your local machine and then setup the
outbound security on it to authenticate to the smtp server you'd like to
relay through. This isn't a very elegant solution, but it's better then
writing your own SMTP protocol class.

you need to use a third party component like:
www.aspNetEmail.com or
http://www.smtpdotnet.com/

Hope this helps you

Thanks
Raghavendra
 
Hi,

The component provided with the framework does not support auth. you have
to use a third party component. take a look inthe archives as this as been
discussed before and see what other people are using.

Pd.
I haven;t heard if the version shipping with 2.0 support this already, does
anybody knows?

cheers,
 
Ken,

If you are using .Net framework 1.1 then you can use the "Fields" property
of a MailMessage to set the required Username/Password.

I have not tested this, but something like ought to do what you need:

// begin snippet
MailMessage mail = new MailMessage();
mail.To = recipient;
mail.From = sender;
// set other properties here
mail.Fields.Add( CdoConfiguration.cdoSMTPAuthenticate, "1" );
mail.Fields.Add( CdoConfiguration.cdoSendUserName, username );
mail.Fields.Add( CdoConfiguration.cdoSendPassword, password );
// now set the SMTP port otherwise SMTPAuthenticate can be ignored.
mail.Fields.Add( CdoConfiguration.cdoSMTPServerPort, smtpPort );
// add other configuration fields as needed (see MSDN library under
// CdoConfiguration)
SmtpMail.Send( mail );
//end snippet

hope this helps,
--philip
 
Thanks!

This is really interesting. I have not tried it yet, but I was wondering if
you could explain how this works, if in fact it does work?


--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
Back
Top