469,927 Members | 1,995 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

System.Web.Mail in a console app?

ES
Hello,
I have very simple console app that attempts to send an email using
system.web.mail. I compiles and runs without any errors but doesn't send
anything. I've checked the badmail folder, etc and I don't see anything.

Should the mail object work in a console app? I've changed the addresses
shown for this message. The actual programm had valid addresses.

The entire program is:

Imports System.Web.Mail
Module Mailer
Sub Main()
Dim m As MailMessage = New MailMessage
m.To = "fo*@bar.com"
m.From = "fo*@bar.com"
m.Subject = "The webserver SMTP service is running"
m.Priority = MailPriority.Low
m.Body = "The webserver SMTP service is running at: " &
CStr(DateTime.Now)
m.BodyFormat = MailFormat.Text
SmtpMail.Send(m)
End Sub
End Module
Jul 21 '05 #1
5 3165
Try setting the SMTP server prior to sending the mail.

System.Web.Mail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"ES" <se****@foo.net> wrote in message
news:uZ*************@TK2MSFTNGP15.phx.gbl...
Hello,
I have very simple console app that attempts to send an email using
system.web.mail. I compiles and runs without any errors but doesn't send
anything. I've checked the badmail folder, etc and I don't see anything.

Should the mail object work in a console app? I've changed the addresses
shown for this message. The actual programm had valid addresses.

The entire program is:

Imports System.Web.Mail
Module Mailer
Sub Main()
Dim m As MailMessage = New MailMessage
m.To = "fo*@bar.com"
m.From = "fo*@bar.com"
m.Subject = "The webserver SMTP service is running"
m.Priority = MailPriority.Low
m.Body = "The webserver SMTP service is running at: " &
CStr(DateTime.Now)
m.BodyFormat = MailFormat.Text
SmtpMail.Send(m)
End Sub
End Module

Jul 21 '05 #2
Sorry;
System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:qD*******************@news2.e.nsc.no...
Try setting the SMTP server prior to sending the mail.

System.Web.Mail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"ES" <se****@foo.net> wrote in message
news:uZ*************@TK2MSFTNGP15.phx.gbl...
Hello,
I have very simple console app that attempts to send an email using
system.web.mail. I compiles and runs without any errors but doesn't send
anything. I've checked the badmail folder, etc and I don't see anything.

Should the mail object work in a console app? I've changed the addresses
shown for this message. The actual programm had valid addresses.

The entire program is:

Imports System.Web.Mail
Module Mailer
Sub Main()
Dim m As MailMessage = New MailMessage
m.To = "fo*@bar.com"
m.From = "fo*@bar.com"
m.Subject = "The webserver SMTP service is running"
m.Priority = MailPriority.Low
m.Body = "The webserver SMTP service is running at: " &
CStr(DateTime.Now)
m.BodyFormat = MailFormat.Text
SmtpMail.Send(m)
End Sub
End Module


Jul 21 '05 #3
ES
Thanks for replying
Adding the line
SmtpMail.SmtpServer = "webmail.myservername.com"

results in an unhandled httpexception, "Could not access CDO.Message
object".

I use my original code in aspx web pages successfully, and I use cdonts with
asp classic pages successfully all the time. Any other thoughts? I'm
willing to try anything.

The point of this is to do some console apps to replace vbs scripts I use
for various things that don't have a UI...

Elton

"Dennis Myrén" <de****@oslokb.no> wrote in message
news:dE*******************@news2.e.nsc.no...
Sorry;
System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:qD*******************@news2.e.nsc.no...
Try setting the SMTP server prior to sending the mail.

System.Web.Mail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"ES" <se****@foo.net> wrote in message
news:uZ*************@TK2MSFTNGP15.phx.gbl...
Hello,
I have very simple console app that attempts to send an email using
system.web.mail. I compiles and runs without any errors but doesn't
send anything. I've checked the badmail folder, etc and I don't see
anything.

Should the mail object work in a console app? I've changed the
addresses shown for this message. The actual programm had valid
addresses.

The entire program is:

Imports System.Web.Mail
Module Mailer
Sub Main()
Dim m As MailMessage = New MailMessage
m.To = "fo*@bar.com"
m.From = "fo*@bar.com"
m.Subject = "The webserver SMTP service is running"
m.Priority = MailPriority.Low
m.Body = "The webserver SMTP service is running at: " &
CStr(DateTime.Now)
m.BodyFormat = MailFormat.Text
SmtpMail.Send(m)
End Sub
End Module



Jul 21 '05 #4
ES
Per your suggestion, I looked up that property in the help. Oops. The
local smtp server doesn't go there, the relay server does. I've got it
going on my local machine, relaying through exchange.

It's still not going anywhere on the web server, which doesn't use a relay
server though.

Elton

"Dennis Myrén" <de****@oslokb.no> wrote in message
news:dE*******************@news2.e.nsc.no...
Sorry;
System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:qD*******************@news2.e.nsc.no...
Try setting the SMTP server prior to sending the mail.

System.Web.Mail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"ES" <se****@foo.net> wrote in message
news:uZ*************@TK2MSFTNGP15.phx.gbl...
Hello,
I have very simple console app that attempts to send an email using
system.web.mail. I compiles and runs without any errors but doesn't
send anything. I've checked the badmail folder, etc and I don't see
anything.

Should the mail object work in a console app? I've changed the
addresses shown for this message. The actual programm had valid
addresses.

The entire program is:

Imports System.Web.Mail
Module Mailer
Sub Main()
Dim m As MailMessage = New MailMessage
m.To = "fo*@bar.com"
m.From = "fo*@bar.com"
m.Subject = "The webserver SMTP service is running"
m.Priority = MailPriority.Low
m.Body = "The webserver SMTP service is running at: " &
CStr(DateTime.Now)
m.BodyFormat = MailFormat.Text
SmtpMail.Send(m)
End Sub
End Module



Jul 21 '05 #5
ES
ARRRHGGGHH!!!!!

It also seems that it helps if your Exchange admin doesn't blow away your
alias!
It's working

Thanks
Elton (what's the emoticon for blushing?)

"Dennis Myrén" <de****@oslokb.no> wrote in message
news:dE*******************@news2.e.nsc.no...
Sorry;
System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:qD*******************@news2.e.nsc.no...
Try setting the SMTP server prior to sending the mail.

System.Web.Mail.SmtpServer = "www.yourserver.com";

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"ES" <se****@foo.net> wrote in message
news:uZ*************@TK2MSFTNGP15.phx.gbl...
Hello,
I have very simple console app that attempts to send an email using
system.web.mail. I compiles and runs without any errors but doesn't
send anything. I've checked the badmail folder, etc and I don't see
anything.

Should the mail object work in a console app? I've changed the
addresses shown for this message. The actual programm had valid
addresses.

The entire program is:

Imports System.Web.Mail
Module Mailer
Sub Main()
Dim m As MailMessage = New MailMessage
m.To = "fo*@bar.com"
m.From = "fo*@bar.com"
m.Subject = "The webserver SMTP service is running"
m.Priority = MailPriority.Low
m.Body = "The webserver SMTP service is running at: " &
CStr(DateTime.Now)
m.BodyFormat = MailFormat.Text
SmtpMail.Send(m)
End Sub
End Module



Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bryan Martin | last post: by
2 posts views Thread by Greg Chu | last post: by
12 posts views Thread by kimiraikkonen | last post: by
1 post views Thread by WIzmanG | last post: by
5 posts views Thread by Henry Stock | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.