Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2003, 03:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default Sending Email with ASP.NET

Dim objMail As New MailMessage()
        objMail.From = "myemailaddress"
        objMail.To = "myemailaddress"
        'objMail.Cc = "[email protected]"
        'objMail.Bcc = "[email protected]"
        objMail.BodyFormat = MailFormat.Text
        objMail.Priority = MailPriority.High

        objMail.Subject = "My first ASP.NET email"

         objMail.Body = "This is my first email sent via ASP.NET."

         SmtpMail.SmtpServer = "servername"
         SmtpMail.Send(objMail)
------------------------------------------

It fails because it was rejected due to "Client was not authenticated". In ASP 3.0 with CDO I used this code:

objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer) = "servername"
objConfig.Fields(cdoSMTPServerPort) = 25
objConfig.Fields(cdoSMTPAuthenticate) = 2
objConfig.Fields(cdoSendUserName) = "ausername"
objConfig.Fields(CdoSendPassword) = "apassword"

Does ASP.NET have this option?
 
Old September 17th, 2003, 03:50 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I would say from looking at the members list of System.Web.Mail.MailMessage that you can't. And by the sounds of it your mail server is pretty well buttoned up.

I think if you omit setting SmtpServer the object will try to use the localhost SMTP server in IIS. That might work for you.

Peter
 
Old September 18th, 2003, 07:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

If I omit it this is the error that I get:

"The "SendUsing" configuration value is invalid"

I'll enable windows authentication and see what that does.
 
Old September 18th, 2003, 09:15 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Now you have me confused. What "SendUsing" configuration value? I don't recall seeing a SendUsing property in System.Web.Mail.MailMessage.

Peter
 
Old September 18th, 2003, 09:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I was following along with this article:

http://www.sitepoint.com/article/1030
 
Old September 18th, 2003, 10:14 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If I recall correctly, SendUsing is what used under the hood as the mail server. It defaults to localhost, but you can override it with the SmtpServer property of the SmtpMail class.

Apparently, you don't have an SMTP Server installed on the machine that tries to send the e-mail, so the Send call fails.

I know of no way to authenticate using the SmtpMail class. You can, however as Peter pointed out, install a local SMTP server. This mail server can then forward your e-mail to your ISP's mail server.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 18th, 2003, 10:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

It's installed and running because it's being used right now for classic asp 3.0.

But Peter is right, it is locked down so it won't get 'black listed'. The server person has locked it down.
 
Old September 18th, 2003, 12:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I changed the SmtpMail.SmtpServer = "servername" to "localhost" and got a can't relay message.

So, I looked at an email from a someone who works across the campus and saw that he was using an email server that allows outside access and used that server name and it worked. My server is [u]intranet</u> only because of ip restrictions. I wonder if that has anything to do as to why it didn't work?

Thanks for your help Peter and Imar.
 
Old September 18th, 2003, 12:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

As long as the following conditions are met, you should be able to send mail thru a mail server using the .Net mail classes:

A. You can access the server via an IP connection (inside a network or outside)
B. The mail server does not require authentication to drop mail onto it. (This is most likely the cause of problems.)
C. The mail server is running (You never know! ;))

Whether or not mail dropped onto a valid SMTP server will get OUT is a different issue. In the case of the IIS SMTP server, I believe it makes the connection to the appropriate mail server itself. It shouldn't even need to know about another mail server to get the mail out (i.e. it doesn't need to talk to your company's public mail server.)

One thing to note regarding sending mail. Let's say my company's mail server is mail.mycompany.com. If I use the .Net mail classes to send mail, the mailmessage class talks directly to that server and I'm trying to send mail to "[email protected]", I have to ensure that there is actually an account for "someaddress" on that mail server. You'll get an immediate failure when you try to create the message on the SMTP when that SMTP is on the same mail system as the POP server that will eventually handle any recipient's address. Hope that makes sense. However, when you use "localhost" (IIS SMTP on the web server) you shouldn't have a problem. If the email address is bad, the message will just bounce and probably end up in the bit bucket unless you used a real "from" address.

The authentication issue may be a discussion to have with the mail server administrator. In most LAN configuration's I've seen, the SMTP service is set up so that anyone who's on the local network can drop mail. From the outside (public IP addresses) only users who have authenticated into POP can drop mail. I think the server recognizes the user's IP address and allows mail relay from that address for some predetermined amount of time. Additionally, the SMTP service (if capable) can be set up to require authentication to send mail. Typically, allowing accessive security from the outside is acceptable, but usually that much security from inside the LAN is not necessary. IMO, if the mail server administrator is that worried/paranoid about someone unauthorized accessing the mail server from the LAN s/he should be more worried about how they got into the LAN in the first place!

There's my dissertation on accessing mail servers. :)

Peter
 
Old October 23rd, 2003, 03:00 PM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

All you have to do is go to your smtp properties...select the access tab...under relay select all computers except or list the ip address of your machine.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending email in VB.net lowell .NET Framework 2.0 3 November 30th, 2008 11:51 AM
sending email from asp.net/sqlserver on a particul hepsy.i ASP.NET 1.0 and 1.1 Professional 1 July 11th, 2008 08:09 AM
How to Sending an email in asp.net 2.0 using C# Bashu C# 2005 4 August 14th, 2007 03:29 AM
sending email through asp.net [email protected] .NET Framework 1.x 2 October 19th, 2006 12:13 PM
Error in sending email from asp.net asif_sharif ASP.NET 1.0 and 1.1 Professional 4 January 7th, 2006 05:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.