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

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
-----------------------------------
 
R

Raghavendra T V

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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,
 
P

Philip Ross

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
 
K

Ken Varn

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
-----------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top