Using the new System.Net.Mail Namespace

Z

zacks

I am trying to figure out how to send SMTP with the new .NET Mail
Namespace. I can send email to an address in my own domain, but when I
try to send email to someone in a different domain I get the relay
access denied error indicating some kind of authentication problem. Out
SMTP server appears to require authentication to send email to
addresses outside of our domain. My Outlook setup indiates that my
authentication is simply my email address and password. But I cannot
figure out how to pass a mailbox/password pair as authentication
credentials. My address is being specified as the From address in the
MailMessage object. And I have tried using default credentials with no
luck. I have also done extensive research on the web and msdn, but
cannot find anything that helps me get over this hurdle. What is the
trick?

In case you are interested, here is the code I am using:

Dim FromAddress As New MailAddress("(e-mail address removed)", "My Personal
Name")
Dim ToAddress As New MailAddress("(e-mail address removed)", "To Familiar
Name")
Dim msg As New MailMessage(FromAddress, ToAddress)
Dim smtpSender As New SmtpClient("my smtphost.com")

msg.Subject = "This is a test message sent from a VB.NET application"
msg.Body = "Let me know if you got this"
smtpSender.UseDefaultCredentials = True
smtpSender.Port = 25
smtpSender.Send(msg)
 
C

Cor Ligthert [MVP]

Zacks,

The most important thing using this is that you use a good SMTP mailserver,
that can be any mailserver that allows to send mails from outside its own
domain, I get the idea, that this is filtered in the mailserver that you are
using. Although it should than as well not send mails inside its domain.

Cor
 

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

Top