Sending Email via VB.Net

E

Ed Bitzer

I have just written a utility (with help from this forum) to
automatically send a sign-up sheet to a dozen tennis friends using
Smtp.Send() from the System.Web.Mail namespace. I question that this
message goes through my ISP's SMTP server (Comcast) since I have not
identified that server or provided a password as required in my set up
of OE or Thunderbird. From what I read it does it's own DNS lookup for
each of the addresses. Is this ok with ISPs?

Ed
 
P

Patrice Scribe

AFAIK unless you explicitely configured something in your code, it is
likeley it uses the local SMTP server. Do you have a local SMTP server (it
is part of the IIS setup) ?

Patrice
 
C

Cor Ligthert [MVP]

A little addition to Partice message

On professional or Server Windows OS.

By instance not on Me and XP home.

Cor
 
E

Ed Bitzer

Cor Ligthert said:
A little addition to Partice message

On professional or Server Windows OS.

By instance not on Me and XP home.

Cor


Cor and Patrice,
I was delinquent in providing full detail. I am running XP-Home and
no IIS. I have provided no username, password or SMTP server
identification (i.e. smtp.comcast.com). Simply state Smtp.Send(my
address, to addresses, subject and message) in the Form load and after
a timer delay to be sure it sends, Application.Exit, and it is working
great. I'll run the exe from a scheduler each week

Ed
 
S

Stephany Young

Hmmmmm ... Smtp.Send ????

Would be interesting to see your code and relevant portions of your
configuration files.
 
R

Rick

I am with Stephanie in wanting to see your code.

I have a local IIS server running from a terminal server and send various
emails to clients. With Comcast in particular, I always fail with the local
SMTP server since Comcast bounces the message back saying that it needs to
have a reverse DNS entry available to authenticate the mail source (or
somehting like this message). With a privately addressed SMTP server this
is not possible.

Please let us know how you are doing this.

Rick
 
L

Lucvdv

Cor and Patrice,
I was delinquent in providing full detail. I am running XP-Home and
no IIS. I have provided no username, password or SMTP server
identification (i.e. smtp.comcast.com). Simply state Smtp.Send(my
address, to addresses, subject and message) in the Form load and after
a timer delay to be sure it sends, Application.Exit, and it is working
great. I'll run the exe from a scheduler each week

I concur with the others: I'd like to see that code.

These two lines in VB.Net:

Dim sx As New SmtpClient
sx.Send("(e-mail address removed)", "(e-mail address removed)", "Test", "Test")

cause an exception

"The SMTP host was not specified."

My idea of what that means is that you (or someone) must have specified a
mailserver somewhere, or you'd have run into the same exception.
That doesn't necessary have to be in your code: the SMTP server can also be
specified in the .Net application or machine configuration file.

But now I'm beginning to wonder: it isn't done often AFAIK, but the SMTP
server can also be passed as a DHCP option (option 069) when your PC
receives its IP address. What I don't know is if Windows/.Net CLR would
use it as default if your network admin had set it up that way.



As for username and password, that's another matter: you normally don't
need those to send mail, only to retrieve mail from a POP account.

SMTP is in essence an authenticationless protocol, it will accept mail from
anybody (which is why there's so much spam going around, which in turn is
the reason why they started building in restrictions, but that story is too
long for this message).



This version works (here, for me, if I replace the addresses by real ones):

Dim sx As New SmtpClient
sx.Host = "10.1.0.5"
sx.Send("(e-mail address removed)", "(e-mail address removed)", "Test", "Test")
 
E

Ed Bitzer

The code is brief,
Imports System.Web.Mail
and in the Form1_Load
SmtpMail.Send("(e-mail address removed)", strAddressList, strSubject,
strEmailMsg)

where strAddressList is in the form aname <[email protected]>;
anothername <[email protected]>
strSubject is "my subject"
strEmailMsg is "my message"

I have successfully sent messages to my Comcast addresses, my Yahoo
address and to a Verizon customer.

My ISP is Comcast and I am connected via a router (I have two
computers) to the modem. I am running XP-Home (fully updated) and
VB.Net Framework 1.1 and the Microsoft Visual Basic.NET (Standard)
2003

I obviously am not feeding you guys enough detail so you will have to
ask specifically.

I did catch Lucdvc's point that username and password are only
necessary for receiving mail. I do however in OE specify the SMTP
server (smtp.comcast.net) where I have not done that here.

Ed
 
S

ShaneO

Lucvdv said:
As for username and password, that's another matter: you normally don't
need those to send mail, only to retrieve mail from a POP account.

SMTP is in essence an authenticationless protocol, it will accept mail from
anybody (which is why there's so much spam going around, which in turn is
the reason why they started building in restrictions, but that story is too
long for this message).
In Australia, just about all ISP's are now stopping SMTP without
authenticating first. To this end, the following is typically what I'm
using in my applications -

Dim SMTPClient As New SmtpClient(sSMTP_Server, iSMTP_Port)
SMTPClient.Credentials = New Net.NetworkCredential(sAccName, sAccPW)
Dim SMTPMessage As New MailMessage(sEmailFROM, sEmailTo, sEmailSubject,
sEmailMessageBody)
If Not String.IsNullOrEmpty(sFileAttachment) Then
Dim EmailAttachment As New Attachment(sFileAttachment)
SMTPMessage.Attachments.Add(EmailAttachment)
End If
SMTPClient.Send(SMTPMessage)

Obviously the above code isn't showing error traps etc., but I trust
this helps the OP.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 
G

Guest

Very much appreciate your sharing code. I have not yet been successful at
sending e-mail with smtp. What are the following parameters?

sSMTP_Server, iSMTP_Port

Also, do you have IIs installed? Not sure if I have to have this installed.
 
E

Ed Bitzer

Dennis and Shane

Dennis said:
Very much appreciate your sharing code. I have not yet been
successful at
sending e-mail with smtp. What are the following parameters?

sSMTP_Server, iSMTP_Port

Also, do you have IIs installed? Not sure if I have to have this
installed.

The SMTPClient requires version 2.0, not the 1.1 that I am running.
Using my simple code I have had no problems but suspect as Shane
indicates Comcast will catch up and require "authentication." I am
about to purchase 2.0 just to get prepared.

Ed
 
S

ShaneO

Dennis said:
Very much appreciate your sharing code. I have not yet been successful at
sending e-mail with smtp. What are the following parameters?

sSMTP_Server, iSMTP_Port

Also, do you have IIs installed? Not sure if I have to have this installed.

The first parameter is for your ISP's SMTP Server name/address, usually
something like "mail.yourISPname.com", or if you have your own SMTP
Server on your network, it can be something like "192.168.1.1".

The iSMTP_Port is the port number used to transfer the message. This is
usually 25.

No, you won't need IIS installed but you do need to ensure you have -

Imports System.Net.Mail

at the top of your application.


ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 
G

Guest

Thanks. Are there any References that I need to add to the project. Note
that I am using VB.Net 2003 so will probably need the IIs installed.
 
S

ShaneO

Dennis said:
Thanks. Are there any References that I need to add to the project. Note
that I am using VB.Net 2003 so will probably need the IIs installed.

You shouldn't need any other References, however I'm using VB.NET 2005
so I can't be sure about 2003. Give it a try and post back if it
doesn't work, maybe another 2003 user could help, if needed.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 

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