Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / October 2004

Tip: Looking for answers? Try searching our database.

System.Web.Mail in a console app?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ES - 26 Oct 2004 20:39 GMT
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 = "foo@bar.com"
       m.From = "foo@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
Dennis Myr?n - 27 Oct 2004 07:53 GMT
Try setting the SMTP server prior to sending the mail.

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

Signature

Regards,
Dennis JD Myr?n
Oslo Kodebureau

> Hello,
> I have very  simple console app that attempts to send an email using
[quoted text clipped - 20 lines]
>    End Sub
> End Module
Dennis Myr?n - 27 Oct 2004 07:54 GMT
Sorry;
System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";

Signature

Regards,
Dennis JD Myr?n
Oslo Kodebureau

> Try setting the SMTP server prior to sending the mail.
>
[quoted text clipped - 24 lines]
>>    End Sub
>> End Module
ES - 27 Oct 2004 21:03 GMT
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

> Sorry;
> System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";
[quoted text clipped - 29 lines]
>>>    End Sub
>>> End Module
ES - 27 Oct 2004 21:13 GMT
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

> Sorry;
> System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";
[quoted text clipped - 29 lines]
>>>    End Sub
>>> End Module
ES - 27 Oct 2004 21:20 GMT
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?)

> Sorry;
> System.Web.Mail.SmtpMail.SmtpServer = "www.yourserver.com";
[quoted text clipped - 29 lines]
>>>    End Sub
>>> End Module

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.