.NETGURU
Smtp problem
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-mail' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

dave wanta (VIP)
-- Moved from [aspngfreeforall] to [ngfx-mail] by Charles M. Carroll <Click here to reveal e-mail address> --

hi all,
I've been sending email using a console app, and all of a sudden it stopped
working. The EXACT same code works as an ASP.NET, but not as a console app.
Here is the non-functional console app code, followed by the WORKING ASP.NET
code. I've been pulling my hair out for 2 days on this. I'm doing this from
the same server, so it's not an SMTP Service config problem, because it's
from the SAME server. Any ideas? The error is:

Unhandled Exception: System.Web.HttpException: Could not access
'CDO.Message' ob
ject. ---> System.Reflection.TargetInvocationException: Exception has been
throw
n by the target of an invocation. --->
System.Runtime.InteropServices.COMExcepti
on (0x80040211): The message could not be sent to the SMTP server. The
transport
error code was 0x80040217. The server response was not available

Console App Code:
******************************
using System;
using System.Web.Mail;
namespace DailyKbEmail2
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.From= "Click here to reveal e-mail address";
msg.To = "Click here to reveal e-mail address";
msg.Subject = "Hello";
msg.Body = "It works!";
SmtpMail.SmtpServer = "mail.kbAlertz.com";
SmtpMail.Send( msg );
}
}
}

Here is the WORKING ASP.NET code
*******************************************
using System;
using System.Web;
using System.Web.Mail;
namespace kbAlertz
{
public class test2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From= "Click here to reveal e-mail address";
msg.To = "Click here to reveal e-mail address";
msg.Subject = "Hello";
msg.Body = "It works!";
SmtpMail.SmtpServer = "mail.kbAlertz.com";
SmtpMail.Send( msg );
Response.Write ("<BR>sent!");
}
}
}

Thanks!
dave

Reply to this message...
 
    
Peter Brunone
Dave,

    Just grasping at straws here, but are you running this code on two
different machines? That is, might the web server not be able to see the
SMTP server while your local dev box can?

-Peter

|-----Original Message-----
|From: dave wanta [mailto:Click here to reveal e-mail address]
|Sent: Wednesday, February 27, 2002 5:39 AM
|To: ngfx-mail
|Subject: [ngfx-mail] Smtp problem
|
|-- Moved from [aspngfreeforall] to [ngfx-mail] by Charles M.
|Carroll <Click here to reveal e-mail address> --
|
|hi all,
|I've been sending email using a console app, and all of a sudden it stopped
|working. The EXACT same code works as an ASP.NET, but not as a console app.
|Here is the non-functional console app code, followed by the
|WORKING ASP.NET
|code. I've been pulling my hair out for 2 days on this. I'm doing this from
|the same server, so it's not an SMTP Service config problem, because it's
|from the SAME server. Any ideas? The error is:
|
|Unhandled Exception: System.Web.HttpException: Could not access
|'CDO.Message' ob
|ject. ---> System.Reflection.TargetInvocationException: Exception has been
|throw
|n by the target of an invocation. --->
|System.Runtime.InteropServices.COMExcepti
|on (0x80040211): The message could not be sent to the SMTP server. The
|transport
| error code was 0x80040217. The server response was not available
|
|Console App Code:
|******************************
|using System;
|using System.Web.Mail;
|namespace DailyKbEmail2
|{
| class Class1
| {
| [STAThread]
| static void Main(string[] args)
| {
| MailMessage msg = new MailMessage();
| msg.From= "Click here to reveal e-mail address";
| msg.To = "Click here to reveal e-mail address";
| msg.Subject = "Hello";
| msg.Body = "It works!";
| SmtpMail.SmtpServer = "mail.kbAlertz.com";
| SmtpMail.Send( msg );
| }
| }
|}
|
|Here is the WORKING ASP.NET code
|*******************************************
|using System;
|using System.Web;
|using System.Web.Mail;
|namespace kbAlertz
|{
| public class test2 : System.Web.UI.Page
| {
| private void Page_Load(object sender, System.EventArgs e)
| {
| MailMessage msg = new MailMessage();
| msg.From= "Click here to reveal e-mail address";
| msg.To = "Click here to reveal e-mail address";
| msg.Subject = "Hello";
| msg.Body = "It works!";
| SmtpMail.SmtpServer = "mail.kbAlertz.com";
| SmtpMail.Send( msg );
| Response.Write ("<BR>sent!");
| }
| }
|}
|
|Thanks!
|dave

Reply to this message...
 
    
Guha, Rahul
I was getting SAME error yesterday while my smtpServer didn't have
permission for relaying the email address ( a typical network issue ). I
tried with some different servers and finally got it working.

-----Original Message-----
From: dave wanta [mailto:Click here to reveal e-mail address]
Sent: Wednesday, February 27, 2002 3:39 AM
To: ngfx-mail
Subject: [ngfx-mail] Smtp problem

-- Moved from [aspngfreeforall] to [ngfx-mail] by Charles M. Carroll
<Click here to reveal e-mail address> --

hi all,
I've been sending email using a console app, and all of a sudden it stopped
working. The EXACT same code works as an ASP.NET, but not as a console app.
Here is the non-functional console app code, followed by the WORKING ASP.NET
code. I've been pulling my hair out for 2 days on this. I'm doing this from
the same server, so it's not an SMTP Service config problem, because it's
from the SAME server. Any ideas? The error is:

Unhandled Exception: System.Web.HttpException: Could not access
'CDO.Message' ob
ject. ---> System.Reflection.TargetInvocationException: Exception has been
throw
n by the target of an invocation. --->
System.Runtime.InteropServices.COMExcepti
on (0x80040211): The message could not be sent to the SMTP server. The
transport
error code was 0x80040217. The server response was not available

Console App Code:
******************************
using System;
using System.Web.Mail;
namespace DailyKbEmail2
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.From= "Click here to reveal e-mail address";
msg.To = "Click here to reveal e-mail address";
msg.Subject = "Hello";
msg.Body = "It works!";
SmtpMail.SmtpServer = "mail.kbAlertz.com";
SmtpMail.Send( msg );
}
}
}

Here is the WORKING ASP.NET code
*******************************************
using System;
using System.Web;
using System.Web.Mail;
namespace kbAlertz
{
public class test2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From= "Click here to reveal e-mail address";
msg.To = "Click here to reveal e-mail address";
msg.Subject = "Hello";
msg.Body = "It works!";
SmtpMail.SmtpServer = "mail.kbAlertz.com";
SmtpMail.Send( msg );
Response.Write ("<BR>sent!");
}
}
}

Thanks!
dave

| [ngfx-mail] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-mail.asp = JOIN/QUIT

Reply to this message...
 
    
dave wanta (VIP)
Nope,
Same server.

thanks,
dave
----- Original Message -----
From: "Peter Brunone" <Click here to reveal e-mail address>
To: "ngfx-mail" <Click here to reveal e-mail address>
Sent: Wednesday, February 27, 2002 10:12 AM
Subject: [ngfx-mail] RE: Smtp problem

[Original message clipped]

Reply to this message...
 
 
System.EventArgs
System.Reflection.TargetInvocationException
System.Web.HttpException
System.Web.Mail.MailMessage
System.Web.Mail.SmtpMail
System.Web.UI.Page




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification