Home All Groups Group Topic Archive Search About

Sending Email via VB.Net

Author
21 Dec 2006 2:54 PM
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

Author
21 Dec 2006 6:00 PM
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


"Ed Bitzer" <edbit***@yahoo.com> a écrit dans le message de news:
u6Jg3$QJHHA.2***@TK2MSFTNGP02.phx.gbl...
Show quoteHide quote
>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
>
Author
21 Dec 2006 6:28 PM
Cor Ligthert [MVP]
A little addition to Partice message

On professional or Server Windows OS.

By instance not on Me and XP home.

Cor

Show quoteHide quote
"Patrice Scribe" <http://www.chez.com/scribe/> schreef in bericht
news:OEPBjnSJHHA.1280@TK2MSFTNGP04.phx.gbl...
> 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
>
>
> "Ed Bitzer" <edbit***@yahoo.com> a écrit dans le message de news:
> u6Jg3$QJHHA.2***@TK2MSFTNGP02.phx.gbl...
>>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
>>
>
>
Author
21 Dec 2006 10:05 PM
Ed Bitzer
Show quote Hide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OcV2Q2SJHHA.816@TK2MSFTNGP06.phx.gbl...
>A little addition to Partice message
>
> On professional or Server Windows OS.
>
> By instance not on Me and XP home.
>
> Cor
>
> "Patrice Scribe" <http://www.chez.com/scribe/> schreef in bericht
> news:OEPBjnSJHHA.1280@TK2MSFTNGP04.phx.gbl...
>> 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
>>
>>
>> "Ed Bitzer" <edbit***@yahoo.com> a écrit dans le message de news:
>> u6Jg3$QJHHA.2***@TK2MSFTNGP02.phx.gbl...
>>>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


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
Author
22 Dec 2006 1:38 AM
Stephany Young
Hmmmmm ... Smtp.Send ????

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


Show quoteHide quote
"Ed Bitzer" <edbit***@yahoo.com> wrote in message
news:ubWr1wUJHHA.3552@TK2MSFTNGP03.phx.gbl...
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:OcV2Q2SJHHA.816@TK2MSFTNGP06.phx.gbl...
>>A little addition to Partice message
>>
>> On professional or Server Windows OS.
>>
>> By instance not on Me and XP home.
>>
>> Cor
>>
>> "Patrice Scribe" <http://www.chez.com/scribe/> schreef in bericht
>> news:OEPBjnSJHHA.1280@TK2MSFTNGP04.phx.gbl...
>>> 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
>>>
>>>
>>> "Ed Bitzer" <edbit***@yahoo.com> a écrit dans le message de news:
>>> u6Jg3$QJHHA.2***@TK2MSFTNGP02.phx.gbl...
>>>>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
>
>
> 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
>
>
Author
22 Dec 2006 1:44 PM
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
Author
22 Dec 2006 2:52 PM
Lucvdv
On Thu, 21 Dec 2006 17:05:45 -0500, "Ed Bitzer" <edbit***@yahoo.com> wrote:

> 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("ad@snipped.invalid", "ad@snipped.invalid", "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("ad@snipped.invalid", "ad@snipped.invalid", "Test", "Test")
Author
22 Dec 2006 8:10 PM
Ed Bitzer
The code is brief,
Imports System.Web.Mail
and in the Form1_Load
SmtpMail.Send("myaddr***@comcast.net", strAddressList, strSubject,
strEmailMsg)

where strAddressList is in the form aname <usern***@xyc.com>;
anothername <usern***@abc.com>
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
Author
22 Dec 2006 8:37 PM
ShaneO
Lucvdv wrote:
>
> 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.
Author
23 Dec 2006 8:50 PM
Dennis
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.
--
Dennis in Houston


Show quoteHide quote
"ShaneO" wrote:

> Lucvdv wrote:
> >
> > 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.
>
Author
24 Dec 2006 1:34 PM
Ed Bitzer
Dennis and Shane

"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:1C839811-7911-4180-9E91-638A69790F53@microsoft.com...
> 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.
> --
> Dennis in Houston

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
Author
25 Dec 2006 3:48 AM
ShaneO
Dennis wrote:
> 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.
Author
25 Dec 2006 6:06 PM
Dennis
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.
--
Dennis in Houston


Show quoteHide quote
"ShaneO" wrote:

> Dennis wrote:
> > 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.
>
Author
25 Dec 2006 8:22 PM
ShaneO
Dennis wrote:
> 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.