473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 3354
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bryan Martin | last post by:
I have a program which has ran every night fine until last night. Now it bombs with the following errors. I have also broke this down to its simplest form for sending the mail...
2
by: Greg Chu | last post by:
Hi, I created a console applicaton and try to import system.web.mail. But I do not see it. after system.web I can only see 3 choices for AspNetHosting..... But I downloaded a sample console app....
5
by: ES | last post by:
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,...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
0
by: Hugh Van | last post by:
Hi all, I'm trying to use .Net.Mail to send email in my program but somehow it always throws me error. I have checked everything in the configuration: username, password, smtpserver, smtp...
2
by: Tim | last post by:
I am trying to send a simple mail message using windows forms in VB.NET 2005. When executing the code, I get a general 'Configuration system failed to initialize' error message when the code...
12
by: kimiraikkonen | last post by:
Hello, I'm trying to create a basic SMTP mail sender using that code, i'm using VB.NET 2005 "express" but this namespace wasn't recognized... (system.web.MAIL) I'm only allowed to declare under...
1
by: WIzmanG | last post by:
Hi all I am having trouble with sending email via a C#2.0 application, I use the same settings as I use in Outlook but I cannot get email to send. I am trying to use SSL on port 465 and get the...
5
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.