DotNet Interface to IIS? Not working

P

Patrick

Environment: Windows 2000 Server SP4, IIS5.0, Dot Net Framework 1.1

Situation:
A Console application that send an email using System.Web.Mail.MailMessage

Observation:
1) Recently, the application is failing to deliver messages!
2) Even when eMails was delivered, there are no entries logged in the SMTP
Log files!
3) I have carried out the following test
3.1) On the Win2K Server where the mail console app is installed, I have
configured Outlook Express to try to send mail using SMTP Server
theServerName, and mail is delivered successfully, with
3.1.1) SMTP Log logging Outlook Express communicating with the IIS Virtual
SMTP Server
3.1.2) SMTP Virtual Server logging relaying the message to external SMTP
Server.

Settings on IIS Virtual SMTP Server
1) Access- Only the list below (127.0.0.1 + the server's IP address)
2) Relay- Only the list below (127.0.0.1 + the server's IP address)- Allow
all computers which successfully authenticate to relay, regardless of the
list above
3) Authentication- Anonymous Access, Basic authentication, Windows Security
package
Default settings for every thing else

Code Snippet-
using System.Web.Mail;
using System.Diagnostics;

[STAThread]
static void Main(string[] args)
{
Class1 cls = new Class1();
cls.createFile();
}

public void createEmail(string sFilePath)
{
// Note this method is explicitly not handling exception. The calling
method should handle it and log to event viewer
MailMessage mail = new MailMessage();
mail.From = sSalesEmail;
mail.To = sExportEmail;

mail.Subject = "Daily order email";

mail.BodyFormat = MailFormat.Text;
MailAttachment attachement = new MailAttachment(sFilePath);
mail.Attachments.Add(attachement);
SmtpMail.Send(mail);
}

public void createFile()
{
try
{
createEmail(strFilePath); //Create the email and send
}

catch(Exception ex)
{
Logging.LogError("Emailer",ex.ToString());
}
}

My biggest biggest concern now is nothing is logged when mail is sent, so I
cannot figure out where the problem lies! How could I fix this? Note that
there are nothing in the bad mail, queued, etc. directory for the email
which should have been sent but haven't.

I have also made one additional interestin observation!
1) Stop SMTP Virtual server on IIS
2) Run the emailing console app
3) Nothing logged in Event Viewer to indicate failure/exceptions in
SmtpMail.Send(mail)
4) Start IIS SMTP Virtual Server
5) Mail relayed successfully (but still nothing logged in SMTP Log file)
 
P

Patrick

Please respond to microsoft.public.dotnet.framework and
microsoft.public.inetserver.iis

(Sorry, posted to microsoft.public.dotnet.framework.aspnet by mistake).
 
S

Steven Cheng[MSFT]

Hi Patrick,

Nevermind, I think we can still discussing this issue here and please post
in the proper group next time:).

From your description, you found your console Applicatoin which use the
System.Web.Mail 's component to send mail not work and without any
exception thrown. Also, you're using the local IIS's smtp Server as the
Smtp Server, yes?

As for this problem, I've also generated a simple test on my side(on a
win2k server with iis5 .net1.1). At first , I also met the problem you
mentioned, the web application run correctly without any exception, but the
mail didn't be sent to the target address. Also, I've check the logfiles in
the "{driver}:\WINNT\system32\LogFiles\SMTPSVC1" foler and found no logs in
it. However, I found that all the mails are queued in the
"{dirver}:\Inetpub\mailroot\Queue" folder. And I also check the EventLog
and found some warnings in it indicate that the mail can't be correctly
sent. After we check the smtp Server's setting and retest again, all the
mails queued in the "{dirver}:\Inetpub\mailroot\Queue" are sent correctly
and also we can find the logs in the
"{driver}:\WINNT\system32\LogFiles\SMTPSVC1" folder.
So currently I think we can perform the following steps:
1. Deleting all the files in the "{dirver}:\Inetpub\mailroot\Queue" folder
and rerun your console appliation to test. After send serveral mails, if
the target user haven't recieved the mail, check the
"{dirver}:\Inetpub\mailroot\Queue" folder to see whether those mails are
there. If they're queued there, we can confirm that the .net code
(System.Web.Mail) is running well and the problem is on the smtpServer
because the System.Web.Mail 's code just help to delivered the mail to the
SMTP server and the mail is actually sent out by the smtpServer.

2. Please double check the eventviewer to see whether there're any warning
or errors indicate failing to send mail.
Also, we need to check the local SMTPServer's setting.

3. After setting the smtpServer, recheck the
"{dirver}:\Inetpub\mailroot\Queue" folder , if the queued mail in it are
all sent out,(the folder become empty), that means the mail has really been
sent out to the target user.

Please check the above things. If you have any updates, please feel free to
post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
G

Guest

This problem is weird and is happening intermittently on a *Production* environment, so I can't do too much on the production environment. However, I could confir
- The Warnings on SMTPSVC in Event Viewer were in regards to a email domain to which the emailing application was not emailin
- Nothing in the SMTP Log files!! (despite logging being enabled explicity, with all fields ticked
- There are items in the Badmail directory, but they were not the ones the emailing application generate

The lack of SMTP Log files mean I cannot track down where the problem lies! I am particularly concern that when SMTP Server is stopped the console application returned with no exceptions!! (Is this by design)

I am particularly very interested in what you did to the Virtual SMTP Server (on IIS5.0 on Windows 2000 SP4 Domain Controller, with all latest patches) to get log entries from being generated even when the mails are sent successfully

Have you tried the following
1) Stop IIS Virtual SMTP Serve
2) Run the application that try to send email (in my case, no exceptions
3) Start IIS Virtual SMTP Serve

I am very concern that log entries are not generated for email sent from the console application. Is this a bug, by design (can't think of why though??), or a "configuration" issue

Btw, what kind of application were you running and in what context when you did manage to get System.Web.Mail to send mail and have the SMTP Log file entry populated? (Mine is a console application, running as a Domain Administrator)

Btw, how could I use System.Diagnostics.Trace to trace to an output file from a console application. I know in ASP.NET, it is jus
<system.diagnostics><trace autoflush="true" indentsize="3"><listeners><add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\\temp\\TraceFile2.txt"/><remove type="System.Diagnostics.DefaultTraceListener"/></listeners></trace></system.diagnostics><system.web><trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/></system.web

But this doesn't work on a console application!
 
W

WenJun Zhang[msft]

Hi Patrick,

Did you get any 4000 or 4001 SMTPSVC warning events in event log? If
so, please paste the details here for us to take a look. The events
can be helpful to determine the problem cause.

Best regards,

WenJun Zhang
Microsoft Online Support
This posting is provided "AS IS" with no warranties, and confers no
rights.
Get Secure! - www.microsoft.com/security
 
P

patrick

No joy, email are still not logged!

Patrick said:
This problem is weird and is happening intermittently on a *Production*
environment, so I can't do too much on the production environment. However,
I could confirm
- The Warnings on SMTPSVC in Event Viewer were in regards to a email
domain to which the emailing application was not emailing
- Nothing in the SMTP Log files!! (despite logging being enabled
explicity, with all fields ticked)
- There are items in the Badmail directory, but they were not the ones the emailing application generated

The lack of SMTP Log files mean I cannot track down where the problem
lies! I am particularly concern that when SMTP Server is stopped the
console application returned with no exceptions!! (Is this by design)?
I am particularly very interested in what you did to the Virtual SMTP
Server (on IIS5.0 on Windows 2000 SP4 Domain Controller, with all latest
patches) to get log entries from being generated even when the mails are
sent successfully.
Have you tried the following-
1) Stop IIS Virtual SMTP Server
2) Run the application that try to send email (in my case, no exceptions)
3) Start IIS Virtual SMTP Server

I am very concern that log entries are not generated for email sent from
the console application. Is this a bug, by design (can't think of why
though??), or a "configuration" issue?
Btw, what kind of application were you running and in what context when
you did manage to get System.Web.Mail to send mail and have the SMTP Log
file entry populated? (Mine is a console application, running as a Domain
Administrator).
Btw, how could I use System.Diagnostics.Trace to trace to an output file
from a console application. I know in ASP.NET, it is just
<system.diagnostics><trace autoflush="true"
indentsize="3"><listeners><add name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\\temp\\TraceFile2.txt"/><remove
type="System.Diagnostics.DefaultTraceListener"/></listeners></trace></system
 
S

Steven Cheng[MSFT]

Hi Patrick,

As I've mentioned in my former reply, the SMTP mail's log won't be created
before the mail queued in the "{dirver}:\Inetpub\mailroot\Queue" folder,
so please check that folder, if all the mails are blocked there, of cousre
we won't find any logs in the log folder. And the problem is in the SMTP
server's configuration. As WenJun Zhang has mentioned, have you found any
4000 or 4001 SMTPSVC warning events in event log? If so, I think it's
better that you provide the detailed error info here so that we can have a
check to see whether there is anything set incorreclty. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top