Newbie - Problem Sending an email via .NET

R

Rob G

Hello,

I am tring to send an email from my local machine (acting as a web server)
on my company's network.

For simplicity sake, I just want to send an email to myself. But I cannot
seem to configure this correctly. Either nothing happens at all, no errors
and no email, but the code seems to run OK, or I get an error saying it
cannot find the Server.

Here's the code:


Public Shared Sub SendEmailToMe()
Dim from As String = "(e-mail address removed)
Dim mailto As String = "(e-mail address removed)"
Dim subject As String = "Test Message"
Dim body As String = "Test the body message"

SmtpMail.SmtpServer = "localhost" 'I've tried my IP address and what I think
is my SMTP is, but I'm not sure

SmtpMail.Send(from, mailto, subject, body)

End Sub

My assumption is that I do not have the SMTPServer configured correctly. But
that is just a guess.
Any insight is greatly appreciated.

Thanks.

-Rob
 
A

ashelley

Public Shared Sub SendEmailToMe()
Dim from As String = "(e-mail address removed)
Dim mailto As String = "(e-mail address removed)"
Dim subject As String = "Test Message"
Dim body As String = "Test the body message"

SmtpMail.SmtpServer = "localhost" 'I've tried my IP address and what I think
is my SMTP is, but I'm not sure

SmtpMail.Send(from, mailto, subject, body)

End Sub

My assumption is that I do not have the SMTPServer configured correctly. But
that is just a guess.
Any insight is greatly appreciated.

Thanks.

-Rob

Where does it exception? What is the exception message?, do you have
the iis smtp relay server running? Can you see the mail anywhere in
inetpub/mailroot/?

-Adam
 
R

Rob G

ashelley,

Here's some other stuff I found:

Since I have the SMTP Server running, I no longer get the exception errors.

I walked through the steps to Test Windows 2000 IIS SMTP Services Manually
as per http://support.microsoft.com/default.aspx?scid=kb;EN-US;286421#Task1
and everything seemed to check out. However, that mail that I sent, when
testing, is still sitting in the Queue directory.

I guess the next step is to figure out why it is not moving from the Queue
to an actual email.

Thanks for your help.

-Rob
 
A

ashelley

ashelley,

Here's some other stuff I found:

Since I have the SMTP Server running, I no longer get the exception errors.

I walked through the steps to Test Windows 2000 IIS SMTP Services Manually
as per http://support.microsoft.com/default.aspx?scid=kb;EN-US;286421#Task1
and everything seemed to check out. However, that mail that I sent, when
testing, is still sitting in the Queue directory.

I guess the next step is to figure out why it is not moving from the Queue
to an actual email.

Thanks for your help.

-Rob

Since you tested it and it is delivering mail by telnetting to it I
think you might need to look at a few things. delete the stuff in the
queue directory, and just try resending. make sure you use the same
email credentials you used while testing. if you use the same
credentials and it doesn't work maybe it is having problems with
permisions on the directories within mailroot. if it keeps failing,
drive a hammer through the front of your screen and go out and enjoy
the sun.

-Adam
 
R

Rob G

ashelley,

Thanks for your help. I think we are getting closer.

It seems that these queued emails are in the Outbox of Outlook Express (I
expected them to be in Outlook). I can't send anything from Outlook Express
because it wants a dialup connection. I would like it to connect to my LAN,
but I can't figure that one out.

Another hour on this and I am going out into the sun and get some fresh air.

-Rob
 
A

ashelley

ashelley,

Thanks for your help. I think we are getting closer.

It seems that these queued emails are in the Outbox of Outlook Express (I
expected them to be in Outlook). I can't send anything from Outlook Express
because it wants a dialup connection. I would like it to connect to my LAN,
but I can't figure that one out.

yeah, umm okay, i assume you mean .eml files. They open in outlook
express because of a file association not because they are sent out
using outlook. I'm not particularly sure, in detail, how the relay
thing works.

What i think might be happenning is that it can't send email to the
domain you are trying to send to. are there any logs in
system32/logfiles/ that help us out?

-Adam
 
R

Rob G

Yep, I mean .EML files. Whoops!

I don't see any logs that are appear to be useful.

I think I understand the file association thing with the EML files, but
Outlook Express has the emails sitting in its Outbox. That is why I assumed
Outlook Express would send the emails.

In the meantime, I tried to switch to sending the emails via Outlook
directly (setting up a reference in .NET) and that is giving me problems to.
That returns a "The information store could not be opened." error when it
tries to get the default folder.

-Rob
 
K

Kevin Spencer

Hi Rob,

Outlook/Outlook Express has nothing to do with sending emails from a Net
app. It is a client program which connects to a POP3 server, or Exchange
Server in order to send emails. The .Net app uses an SMTP server, which you
already know you have on your machine. Don't get them confused.

If the email you're sending has a return address which is not local to your
machine, by default, the IIS SMTP server disallows "relaying," which is,
simply, the transmission of an email which did not originate on that machine
(determined by the return email address's domain name). You may need to
configure your local SMTP server to allow relaying. Be aware, however, that
it is turned off for a reason. You may find SPAMmers using your local SMTP
Server, unless you've blocked incoming traffic on Port 25.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
R

Rob G

Kevin,

This is what I've done so far:

Under Default SMTP Virtual Server I went to Properties.
Clicked the Access tab.
Clicked Relay.
I added my local computer's IP address and 127.0.0.1 (just to test becuase I
don't know what I am doing).
"Only the list below " is selected and so is "Allow all computer which
succesfully authenticate..."

Does that make any sense?

Thanks.

-Rob
 
K

Kevin Spencer

That should do it, Rob.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
R

Rob G

Kevin,

Do you have any idea why the email would be sitting in the Queue directory?
What could I test to see why it doesn't send it out?

Thanks.

-Rob
 
E

Eric

This may help: In the properties of your SMTP server, there are probably
some settings regarding how often to retry sending, time until bounceback,
etc. Set these to a short amount of time and, in your ASP code, set the
From address to be YOUR actual, live, working email address (gumbatman @
hotmail.com).

Hopefully, if there's a problem sending to the domain (or something of that
nature) you will receive a bounce message explaining the problem. You may
also hunt around in the application or security event log for some
information.

This may be a silly question, but, have you verified that the SMTP server
has access to the internet, can get out on port 25, etc. Not having access
would result in the symptoms you are experiencing.


Eric
 
R

Rob G

Eric,

Thanks for the info.

I have been using live email addresses. But how do I confirm that I can get
out on port 25? I know it is basic and silly, but I am new to it.

Thanks.

-Rob
 
E

Eric

Not silly at all - everything's new at some point.
At a command prompt, try typing:

telnet mail.yahoo.com 25

if you connect, and are able to type, you made it out. If you don't connect
or, if it appears to connect, but disconnects after the first keystroke,
you're not able to get out.

Eric
 
R

Rob G

Eric,

Well it seems that I cannot get out on that port.

Just so we're clear. I opened Telnet. Then typed: open mail.yahoo.com 25

I then got the error "Count not open a connection to host on port 25."

I am not sure if you meant "mail.yahoo.com" as a place holder or an actual
string.

What do I do next?

Thanks.
 
E

Eric

Yup, I meant that literally (anyone should be able to connect to
mail.yahoo.com on port 25) so.....
It's a firewall issue. Whatever firewall you're using, you'll need to
permit outbound traffic on port 25. I feel fairly confident that if you do
this your problem will be resolved.

Regards,

Eric
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top