If outgoing server requires authentication?

  • Thread starter Thread starter Coder
  • Start date Start date
C

Coder

If outgoing server requires authentication,

How can I use smtpmail object in c# ?

I use a windows 2003 server hosting packet somewhere...
string from = "(e-mail address removed)";


string to = UserEMail;


string subject = "Subject";


string body = "Test";


SmtpMail.SmtpServer = "smtp.xxx.com";


SmtpMail.Send(from, to, subject, body);
 
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
 

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

Recipient address rejected: Access denied 1
Problems sending emails 1
Emergency 1
Sending Email 3
Sendmail not sending 2
SmtpMail Authentication 1
Cannot smtp in C# - cant connect to server 5
SMTPMAIL 3

Back
Top