By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,106 Members | 2,679 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,106 IT Pros & Developers. It's quick & easy.

This mail sending code snippet does not work

P: n/a
Dim message As New MailMessage("my****@mydomain.com", "my****@mydomain.com",
"Test", "Test")

Dim emailClient As New SmtpClient("localhost")

emailClient.Send(message)

The IIS server is running on the local machine.

What am I missing to make this work reliably?

Thanks for any help

Bob


Nov 4 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Robert,

First of all do you need to set IIS as SMTP server, that is not standard,
you can use the Microsoft tab in the add programs config for that.

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl...
Dim message As New MailMessage("my****@mydomain.com",
"my****@mydomain.com", "Test", "Test")

Dim emailClient As New SmtpClient("localhost")

emailClient.Send(message)

The IIS server is running on the local machine.

What am I missing to make this work reliably?

Thanks for any help

Bob


Nov 5 '06 #2

P: n/a
I'm getting back error Mailbox unavailable. The server response was: 5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine

"Robert Dufour" <bd*****@sgiims.comwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
Dim message As New MailMessage("my****@mydomain.com",
"my****@mydomain.com", "Test", "Test")

Dim emailClient As New SmtpClient("localhost")

emailClient.Send(message)

The IIS server is running on the local machine.

What am I missing to make this work reliably?

Thanks for any help

Bob


Nov 5 '06 #3

P: n/a
Hi Cor
It was already set.
I'm getting back error Mailbox unavailable. The server response was: 5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine.

I was working the local machine where the app was residing via Radmin from
another machine on the LAN and I think maybe this is a security issue, where
I have to specify an SMTP server name, username and password, but I can't
find any info on how to code this.
Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
Robert,

First of all do you need to set IIS as SMTP server, that is not standard,
you can use the Microsoft tab in the add programs config for that.

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>Dim message As New MailMessage("my****@mydomain.com",
"my****@mydomain.com", "Test", "Test")

Dim emailClient As New SmtpClient("localhost")

emailClient.Send(message)

The IIS server is running on the local machine.

What am I missing to make this work reliably?

Thanks for any help

Bob



Nov 5 '06 #4

P: n/a
Robert,

Normaly you get tons of links to this website, therefore I gave you my first
thought the problem was.

http://www.systemwebmail.com/

I hope this helps,

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:uF**************@TK2MSFTNGP04.phx.gbl...
Hi Cor
It was already set.
I'm getting back error Mailbox unavailable. The server response was: 5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine.

I was working the local machine where the app was residing via Radmin from
another machine on the LAN and I think maybe this is a security issue,
where I have to specify an SMTP server name, username and password, but I
can't find any info on how to code this.
Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
>Robert,

First of all do you need to set IIS as SMTP server, that is not standard,
you can use the Microsoft tab in the add programs config for that.

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>>Dim message As New MailMessage("my****@mydomain.com",
"my****@mydomain.com", "Test", "Test")

Dim emailClient As New SmtpClient("localhost")

emailClient.Send(message)

The IIS server is running on the local machine.

What am I missing to make this work reliably?

Thanks for any help

Bob




Nov 5 '06 #5

P: n/a
I also tested to use localhost using system.web.mail instead of the new
system.net.mail
I get an exception : the transport could not connect to the host when using
localhost as the smtp server. When using my mail server outside of my lan
where I am normally hosted(mail.mycompany.com) the message goes through.

There seems to be something wrong with the localhost smtp server but I can't
figure out what.
This is the code snippet I used for that test.

Dim mail As New System.Web.Mail.MailMessage()

mail.To = "bd*****@sgiims.com"

mail.From = "bd*****@sgiims.com"

mail.Subject = "this is a test email."

mail.Body = "this is my test email body"

SmtpMail.SmtpServer = "mail.mycompany.com" 'This works OK but localhost does
not

Try

SmtpMail.Send(mail)

Catch ex As Exception

MsgBox(ex.Message)

End Try


Thanks for your help.
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uj**************@TK2MSFTNGP04.phx.gbl...
Robert,

Normaly you get tons of links to this website, therefore I gave you my
first thought the problem was.

http://www.systemwebmail.com/

I hope this helps,

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:uF**************@TK2MSFTNGP04.phx.gbl...
>Hi Cor
It was already set.
I'm getting back error Mailbox unavailable. The server response was:
5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine.

I was working the local machine where the app was residing via Radmin
from another machine on the LAN and I think maybe this is a security
issue, where I have to specify an SMTP server name, username and
password, but I can't find any info on how to code this.
Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
>>Robert,

First of all do you need to set IIS as SMTP server, that is not
standard, you can use the Microsoft tab in the add programs config for
that.

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl...
Dim message As New MailMessage("my****@mydomain.com",
"my****@mydomain.com", "Test", "Test")

Dim emailClient As New SmtpClient("localhost")

emailClient.Send(message)

The IIS server is running on the local machine.

What am I missing to make this work reliably?

Thanks for any help

Bob




Nov 5 '06 #6

P: n/a
Robert,

Did you already try the IP address of your local computer?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I also tested to use localhost using system.web.mail instead of the new
system.net.mail
I get an exception : the transport could not connect to the host when
using localhost as the smtp server. When using my mail server outside of
my lan where I am normally hosted(mail.mycompany.com) the message goes
through.

There seems to be something wrong with the localhost smtp server but I
can't figure out what.
This is the code snippet I used for that test.

Dim mail As New System.Web.Mail.MailMessage()

mail.To = "bd*****@sgiims.com"

mail.From = "bd*****@sgiims.com"

mail.Subject = "this is a test email."

mail.Body = "this is my test email body"

SmtpMail.SmtpServer = "mail.mycompany.com" 'This works OK but localhost
does not

Try

SmtpMail.Send(mail)

Catch ex As Exception

MsgBox(ex.Message)

End Try


Thanks for your help.
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uj**************@TK2MSFTNGP04.phx.gbl...
>Robert,

Normaly you get tons of links to this website, therefore I gave you my
first thought the problem was.

http://www.systemwebmail.com/

I hope this helps,

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:uF**************@TK2MSFTNGP04.phx.gbl...
>>Hi Cor
It was already set.
I'm getting back error Mailbox unavailable. The server response was:
5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine.

I was working the local machine where the app was residing via Radmin
from another machine on the LAN and I think maybe this is a security
issue, where I have to specify an SMTP server name, username and
password, but I can't find any info on how to code this.
Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
Robert,

First of all do you need to set IIS as SMTP server, that is not
standard, you can use the Microsoft tab in the add programs config for
that.

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl...
Dim message As New MailMessage("my****@mydomain.com",
"my****@mydomain.com", "Test", "Test")
>
Dim emailClient As New SmtpClient("localhost")
>
emailClient.Send(message)
>
The IIS server is running on the local machine.
>
What am I missing to make this work reliably?
>
Thanks for any help
>
Bob
>
>
>
>




Nov 5 '06 #7

P: n/a
Yes Cor I tried that too. But just for the heck of it I tried that again to
confirm. I used either 127.0.0.1 as the host address or 192.168.1.163.
Neither of them worked. My VERY strong suspicion is that I have something
wrong with the smtp server on this computer running under framework 2. I
recall trying to use this before I had framework 2 installed with Vs2003 and
framework with framework1.1 and system.web.mail and it worked fine. Now in
Vs2005 and fraemwork2 I am having these problems. In the last two tests I
did I found that the email messages got created in the Drop directory (two
..eml files with the date and time stamp of the time of the test). I then
retried setting the host to mail.mydomain.com and also sending a message.
That did not seem to work this time either.
Yesterday I had unistalled and reintalled the smtp server on this computer
and enabled logging.
Attached you will find a log file for today (zipped format) the test entrie
are the last few. I'm trying to figure out what the other log entries (the
hotmail ones) for today are, they just seem to repeat and I don't know why.
Also I'm behind an ISA 2004 firewall, but I'm picking up and sending my
email messages to and from my hosted outside accounts via outlook 2003 OK
and it worked fine under framework 1.1 on te host. I also double checked and
made sure to add a rule to the ISA server to allow SMTP on Port 25 to be
used outbound between the protected networks on my lan and the outside
network, although I think its redundant.

I wonder if there is any testing tools that I can use to test the workings
of my local smtp virtual server.

Thanks for your help
Bob

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uL**************@TK2MSFTNGP03.phx.gbl...
Robert,

Did you already try the IP address of your local computer?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I also tested to use localhost using system.web.mail instead of the new
system.net.mail
I get an exception : the transport could not connect to the host when
using localhost as the smtp server. When using my mail server outside of
my lan where I am normally hosted(mail.mycompany.com) the message goes
through.

There seems to be something wrong with the localhost smtp server but I
can't figure out what.
This is the code snippet I used for that test.

Dim mail As New System.Web.Mail.MailMessage()

mail.To = "bd*****@sgiims.com"

mail.From = "bd*****@sgiims.com"

mail.Subject = "this is a test email."

mail.Body = "this is my test email body"

SmtpMail.SmtpServer = "mail.mycompany.com" 'This works OK but localhost
does not

Try

SmtpMail.Send(mail)

Catch ex As Exception

MsgBox(ex.Message)

End Try


Thanks for your help.
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uj**************@TK2MSFTNGP04.phx.gbl...
>>Robert,

Normaly you get tons of links to this website, therefore I gave you my
first thought the problem was.

http://www.systemwebmail.com/

I hope this helps,

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:uF**************@TK2MSFTNGP04.phx.gbl...
Hi Cor
It was already set.
I'm getting back error Mailbox unavailable. The server response was:
5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine.

I was working the local machine where the app was residing via Radmin
from another machine on the LAN and I think maybe this is a security
issue, where I have to specify an SMTP server name, username and
password, but I can't find any info on how to code this.
Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
Robert,
>
First of all do you need to set IIS as SMTP server, that is not
standard, you can use the Microsoft tab in the add programs config for
that.
>
Cor
>
"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl.. .
>Dim message As New MailMessage("my****@mydomain.com",
>"my****@mydomain.com", "Test", "Test")
>>
>Dim emailClient As New SmtpClient("localhost")
>>
>emailClient.Send(message)
>>
>The IIS server is running on the local machine.
>>
>What am I missing to make this work reliably?
>>
>Thanks for any help
>>
>Bob
>>
>>
>>
>>
>
>




Nov 6 '06 #8

P: n/a
I found a document showing how to use telnet to test my virtual server
kb/286421.
I worked through it OK although I found that to get 250 responses to
everything I had to use for the FROM property of the message
myloggedinUsernam@MylanDomainName
BUT during that test the message did not end up in the destination mailbox.
Trying again
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uL**************@TK2MSFTNGP03.phx.gbl...
Robert,

Did you already try the IP address of your local computer?

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I also tested to use localhost using system.web.mail instead of the new
system.net.mail
I get an exception : the transport could not connect to the host when
using localhost as the smtp server. When using my mail server outside of
my lan where I am normally hosted(mail.mycompany.com) the message goes
through.

There seems to be something wrong with the localhost smtp server but I
can't figure out what.
This is the code snippet I used for that test.

Dim mail As New System.Web.Mail.MailMessage()

mail.To = "bd*****@sgiims.com"

mail.From = "bd*****@sgiims.com"

mail.Subject = "this is a test email."

mail.Body = "this is my test email body"

SmtpMail.SmtpServer = "mail.mycompany.com" 'This works OK but localhost
does not

Try

SmtpMail.Send(mail)

Catch ex As Exception

MsgBox(ex.Message)

End Try


Thanks for your help.
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uj**************@TK2MSFTNGP04.phx.gbl...
>>Robert,

Normaly you get tons of links to this website, therefore I gave you my
first thought the problem was.

http://www.systemwebmail.com/

I hope this helps,

Cor

"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:uF**************@TK2MSFTNGP04.phx.gbl...
Hi Cor
It was already set.
I'm getting back error Mailbox unavailable. The server response was:
5.7.1
Unable to relay for my****@mydomain.com
The smtp server is localhost.
The SMTP service is running on the local machine.

I was working the local machine where the app was residing via Radmin
from another machine on the LAN and I think maybe this is a security
issue, where I have to specify an SMTP server name, username and
password, but I can't find any info on how to code this.
Regards,
Bob
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
Robert,
>
First of all do you need to set IIS as SMTP server, that is not
standard, you can use the Microsoft tab in the add programs config for
that.
>
Cor
>
"Robert Dufour" <bd*****@sgiims.comschreef in bericht
news:Oc**************@TK2MSFTNGP02.phx.gbl.. .
>Dim message As New MailMessage("my****@mydomain.com",
>"my****@mydomain.com", "Test", "Test")
>>
>Dim emailClient As New SmtpClient("localhost")
>>
>emailClient.Send(message)
>>
>The IIS server is running on the local machine.
>>
>What am I missing to make this work reliably?
>>
>Thanks for any help
>>
>Bob
>>
>>
>>
>>
>
>




Nov 6 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.