Re: Email Programming using System.Web.Mail
- From: "Stephany Young" <noone@localhost>
- Date: Fri, 18 Jan 2008 09:37:08 +1300
With System.Web.Mail, (1.1), the book for the SmtpMail class says that if you do not specify a value for SmtpServer then it uses the local SMTP server.
If you are not explicitly specifying a value for SmtpServer then you MUST some form of SMTP server running on the machine. You may not necessarily realise that you have such a server running, but you would not be able to send a message via the SmtpMail class without it.
To clarify a point, VB.Net does NOT have any form of SMTP within it and does no 'magic' on your behalf. You must explicitly use the SMTP class(es) provided by the .NET Framework, which are not actually part of Vb.Net per se.
"Ed Bitzer" <edbitzer@xxxxxxxxx> wrote in message news:OqmxzIQWIHA.1188@xxxxxxxxxxxxxxxxxxxxxxx
"Stephany Young" <noone@localhost> wrote in message
news:eIYqnxLWIHA.1188@xxxxxxxxxxxxxxxxxxxxxxx
Time for everyone to get on the same page I think.
The first thing that you need to confirm is that you are, in fact,
using an instance of the System.Net.Mail.SmtpClient class to senn
your emails.
If you're not then it's all back to square one.
If you are then it would be interesting to see how you instantiate
the instance.
'The book' says that if you do not supply a target 'host', either in
the constructor or by setting the Host property then the instance
will use whatever is specified in your application or machine
configuration files. (It will 'look' in the application
configuration first but if that doesn't specify the appropriate
information then it will fall back to the machine configuration
file.) While it doesn't say so in so many words, it implies that it
doesn't 'look' anywhere else, therefore I would expect that, if you
don't specify it and it isn't specified in either of the
configuration files, an exception would be thrown when you call the
Send method.
I have just confirmed this by using:
Dim _client As New SmtpClient
_client.Send(New MailMessage("fromaddress", "toaddress", "Test",
"Test"))
It results in an InvalidOperationException with the message 'The
SMTP host was not specified.'.
The moment I specify a valid server then it works:
Dim _client As New SmtpClient("server")
_client.Send(New MailMessage("fromaddress", "toaddress", "Test",
"Test"))
If you are definitely NOT specifying a 'host' in your code then that
means that you MUST have a 'host' specified in one or more of your
config files. All it is now, is a matter of you looking to see what
it is. I know of no automatic mechanism that will put such
information in the configuration files (but that doesn't mean such a
mechanism doesn't exist).
The SmtpClient class is, as it's name suggests, a 'client' object
and not a 'server' object. It will only connect to an 'up-line' SMTP
server. If the recipient's 'mailbox' is not directly served by that
server then the message will be relayed on to the appropriate
server.
"Ed Bitzer" <edbitzer@xxxxxxxxx> wrote in message
news:evO2gSIWIHA.5816@xxxxxxxxxxxxxxxxxxxxxxx
"rowe_newsgroups" <rowe_email@xxxxxxxxx> wrote in message
news:d3d28beb-9f22-4180-a2bf-e0e83fb07327@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jan 16, 12:19 pm, "Ed Bitzer" <edbit...@xxxxxxxxx> wrote:I have been able using the namespace System.Web.Mail and its
method
Smtp.mail.send to mail simple text messages to a small group
within
our 55 and older community. I need help expanding the programs
capabilities. Searching this forum I did not find any related
information so if I have chosen poorly, I would appreciate a
suggestion of a more appropriate dotnet forum.
Now what I wish is the ability to send bcc's rather than to:
(would be
sending to all 250 residents and would have to send in groups of
50 as
required by Comcast to curtail spammers) and also wonder if this
namespace handles base64 encoding so that I can send a pdf
attachment.
Appreciate,
Ed
Though it might not help with encoding (not sure) two excellent
sites
you need to check out are:
http://www.systemwebmail.com/
And
http://www.systemnetmail.com/
IMO if you are using 2.0 or higher you should be using
System.Net.Mail
Thanks,
Seth Rowe [MVP]
Seith and Patrice too,
I have waded my way through all the references gave and digested
sufficiently to create a prototype that sends an email To:
somebody, with Bcc's to several others and can handle one or more
pdf attachments encoded with Base64 - and it works<g>. Obviously
you guys gave me excellent directions. I do have one more
questions and that is how is this stuff getting to the recipients.
I am sending from my home. I am providing system.web.mail with no
information about my ISP. Does my program act as a Server and do
its own thing looking up the DNS information for each of the
recipients ISP's? When I use commercial software such as
Thunderbird or OE I must spell out the smtp servicer and provide a
username and password.
Ed
Stephany,
I just want you and the others to know how much I appreciate your
efforts on my behalf. I need to digest your latest comments but first
I want all to know that I have a prototype working thanks to the
references given, especially the excellent summary of threads provided
at www.systemwebmail.com. (I am using Net 1.1 and
therefore System.Web.Mail) If I do not provide an SMTP server the
program works (my simple minded understanding is that VB.Net has a
basic SMTP code within but better yet I can specify my local ISP,
provide the username and password. If I understand correctly by this
is safer avoiding any reflection that my ISP is providing an open
relay.
Ed
.
- References:
- Email Programming using System.Web.Mail
- From: Ed Bitzer
- Re: Email Programming using System.Web.Mail
- From: rowe_newsgroups
- Re: Email Programming using System.Web.Mail
- From: Ed Bitzer
- Re: Email Programming using System.Web.Mail
- From: Stephany Young
- Re: Email Programming using System.Web.Mail
- From: Ed Bitzer
- Email Programming using System.Web.Mail
- Prev by Date: Re: List Colors At Runtime
- Next by Date: Re: A request from lazy newbie - Web app util
- Previous by thread: Re: Email Programming using System.Web.Mail
- Next by thread: Re: Email Programming using System.Web.Mail
- Index(es):
Relevant Pages
|
|