Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seding Email... (yes, I looked on google)

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
US
Hi All...
Ok, this is reaching quite high annoying frustration levels.. I'm trying to send an email and I have looked all over google. All sites found agree that I should:

1 - Configure IIS using the localhost to relay emails.
2 - Use either SmptMail with (or without) MailMessage

I've done exactly what they told me to, yet when I test it, I send an email to myself and I get nothing. No error and no email. Grrrr! What am I missing?

I have Windows 2000 and .NET 2002, and this is what I did:

1 - On the "Default SMTP Virtual" properties, I went to Authentication and made sure only the Anonymous access checkbox was selected. Then, I went to Relay, and typed in the 127.0.0.1 IP address (just like they said).

2 - To send the email, I have the code:
Code:
SmtpMail.SmtpMailServer = "localhost";
SmtpMail.Send(from, to, subject, body);
I press the button where the code is and nothing happens. I have tripple, quadruple and quintuple check the address and all the settings. Everything is in place, and I sill get no email.

What am I missing?

Thanks.

JC


_________________________________
I think, therefore I am. [Rene Descartes]
 
Thanks Mike...
Yes, the SMTP service is started. I'll restart it, just to to see what happens. Any other suggestions?

Thanks again.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
I mean, let me get this straight? Anyone with .NET installed on his computer can send email, whether he has an email account or not? Is that how this works? I haven't setup any email server on IIS, and that's what puzzles me. Yet, none of the articles I've found online even mention that someone might think an email server is needed. So I'm assumming that with the settings I've mentioned earlier (the relay and authentication stuff) by themselves should do the trick. Am I right? If not, then what is it that I'm missing...

Thanks.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
It's not really as easy as that and I know our network guys had quite a lotof hassle setting ours up (personally, I didn't have to get involved so I'm not sure of the exact details). I do know that you have to make sure that you have a SMTP server that is capable of relaying messages though and this may be where you problem lies. Here's an MSDN article that may explain in a bit more details:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanks ca8msm!

Well, all the articles I've read point out that you COULD specify your own smtp server, in which case the process would be different. However, they say that you could just use localhost with the settings I described earlier, and you should have no problems whatsoever. One of the articles I've read goes something like this:

"If you experience problems sending emails, it might that the smtp server on IIS is not setup properly. To correct the problem, do this:". And it goes on to showing you how to specify 127.0.0.1 on the relay options, and selecting "Anonymous access only" on the authentication options. Then, it says: "ok, now your server is properly setup." Grrrrr!!!!

I'll keep looking... In the mean time, if anyone has any ideas, please post.

Thanks.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
Try this: it should work fine.

Dim objMM As New MailMessage()
objMM.To = "receive@yahoo.com"(Receiver Email Address) objMM.From = email
objMM.BodyFormat = MailFormat.Html (html format)
objMM.Subject = "bla bla"
objMM.Body = "<html><body>bla bla</body></html>"
SmtpMail.Send(objMM)
end if
 
Thanks znet,

I'm sorry I don't understand what you would like me to do.

This is what I'm doing:
Code:
Dim from As String = txtFrom.Text
Dim to As String = txtTo.Text
Dim subject As String = "Test Subject"
Dim body As String = "Test Body"
SmtpMail.Send(from, to, subject, body)
This is the same as using the MailMessage class, so in essence, I think I'm already doing what you're telling me to do.

How did you set up your SMTP server on IIS?

Thanks again.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
Hi JC,
I didn't set up SMTP intendly, I am sure this code works fine to send email. I use it in our living web site.

Regards
znet
 
Thanks again...

That's what puzzles me. Every article that I find online gives me the very same code. Yet, when I try it, I get no error messages, but the email is still not sent. Any idea what might be happenning?

Thanks again.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
The code that you are using will (most probably) not be the problem - as you said in your orginal post, you have already tried using the MailMessage class.

It's most likely the setup of the SMTP server that is the problem. Try posting a question in one of the windows forums on how to successfully set one up.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
This is how I do it..

Private Sub Email()

Dim objMM As New MailMessage()

objMM.To = lblEmail.Text
objMM.From = "Whatever"
objMM.Subject = "Whatever"
objMM.Body = "Whatever"
SmtpMail.SmtpServer = "Email Server's IP Address"

SmtpMail.Send(objMM)

SmtpMail.SmtpServer = ""



 
Hi JC,
I try my code again in local server, it works fine, the SMTP is defaultly setup and I didn't use SmtpServer IP as dvannoy's code. But you should note this sentence: objMM.From="Whatever", the sender email, it must be VALID email address. And try different type of receiver email address, In my case, using Hotmail, received email very quickly, but using Yahoo, received nothing after sending for several hours.

Regards
znet
 
Thank you all....

Guys listen to this... I turned my computer on today and then went ahead and checked my mail... Guess what... All the emails where sent... Today. Not yesterday, but today. I received all the emails today, and the date and time on them is today's date and time (right when I turned my machine on). Thus, perhaps I needed to refresh or restart IIS and the SMTP service. I tried about 2 hours ago today to send email, then I restarted my machine, and got nothing yet.

Does anyone know what may be happenning?

Thanks.

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
As I pointed out in my last post, I didn't think you would have a problem with the actual code and it was more likely to be a problem with the SMTP service. Try asking in a windows related forum (e.g. forum616) as they may know more about the actual problem).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hey Guys,
I had to resort to microsoft to resolve the issue. My computer connects to the internet through another computer on the network, and the DNS and IP address are assigned automatically. The IP address of the computer through which I connect was what was being used as the DNS and this is what was causing the problem. Had my computer been connected directly to the internet, I would have had no problem. To go around the issue, we installed the DNS service on my machine and configured it so that it forwards outside emails to the machine through which I connect. Then, the IP address on my machine was made static, and the DNS assigned was my machine itself (since the DNS service was installed).

Thanks for your effort guys!

JC

_________________________________
I think, therefore I am. [Rene Descartes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top