HELP: ASP.NET Site Sending E-mail and Writing to Event Log



We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles
sending e-mail from the server when accessing the web site from a separate
client computer. Also, in the same scenario, I'm having trouble writing to
the server's event log.

Here's some details:

Server and workstation both in the same workgroup
Logged into server as local Administrator
Logged into workstation as a local user that is only in the Users group on
the workstation
The local user on the workstation is also defined as a local user on the
server with same name and password (and only in the Users group on the
server too)
Server is Windows Server 2003 running IIS 6.0
Workstation is Windows XP Professional
ASP.NET 2.0 (C#) web site - intranet only, not a public Internet web site


Web.config snippet
<system.web>
<authentication mode="Windows"/>
<identity impersonate="true"/>
</system.web>



For the e-mailing problem
..aspx code-behind code snippet
string fromEmail = "donotreply@xxxxxxxxxxxxxxxxxxxx";
string fromDisplayName = "Testing SendEmail";
string toEmail = "person@xxxxxxxxxxx";
string pathAndFile = @"D:\Temp\testing.log";
string exceptionInfo = "Testing SendEmail";

System.Net.Mail.SmtpClient smtpclient = new
System.Net.Mail.SmtpClient();
smtpclient.DeliveryMethod =
System.Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis;

// For smtpclient.Host, I've tried "localhost", I've tried
System.Net.Dns.GetHostName(),
// and I've tried not setting the property at all
// none of these work
smtpclient.Host = System.Net.Dns.GetHostName();

// For smtpclient.PickupDirectoryLocation, I've tried not setting it
and I've tried
// explicitly setting the path to the IIS pickup folder
// neither of these work
smtpclient.PickupDirectoryLocation = @"C:\Inetpub\mailroot\Pickup";

// For smtpclient.Port, I've tried not setting it and I've tried
explicitly setting it to 25
// neither of these work
smtpclient.Port = 25;

// For smtpclient.UseDefaultCredentials, I've tried not setting it
and I've tried
// setting it to true
// neither of these work
smtpclient.UseDefaultCredentials = true;

System.Net.Mail.MailAddress from = new
System.Net.Mail.MailAddress(fromEmail, fromDisplayName);
System.Net.Mail.MailAddress to = new
System.Net.Mail.MailAddress(toEmail);
System.Net.Mail.Attachment attachment = new
System.Net.Mail.Attachment(pathAndFile);

using (System.Net.Mail.MailMessage message = new
System.Net.Mail.MailMessage(from, to))
{
message.Attachments.Add(attachment);
message.Body = exceptionInfo;
message.Priority = System.Net.Mail.MailPriority.High;
message.Subject = "Testing SendEmail";

// Exception is throw here trying to call the Send method
smtpclient.Send(message);
}

attachment.Dispose();


The exception details are: System.Net.Mail.SmtpException: Cannot get IIS
pickup directory.

From the client computer, I can navigate to the site and do whatever without
any problems. But, when the site tries to send an e-mail from the server
for the session started by the client in the scenario described above, it
fails.



For the writing to the event log problem
..aspx code-behind code snippet
string exceptionInfo = "Testing WriteToEventLog";
System.Diagnostics.EventLog log = new System.Diagnostics.EventLog();
log.Log = "Application";
log.Source = "Application";

try
{
log.WriteEntry(exceptionInfo,
System.Diagnostics.EventLogEntryType.Error);
}
finally
{
log.Close();
log.Dispose();
}


The exception details are: System.ComponentModel.Win32Exception: Access is
denied (Cannot open log for source 'Application'. You may not have write
access.)

Again, from the client computer, I can navigate to the site and do whatever
without any problems. But, when the site tries to write to the event log on
the server for the session started by the client in the scenario described
above, it fails.



Basically, this is supposed to be an exception notification thing.

Am I doing something wrong? Am I missing something? How can I make the
above scenario work?



Thanks.



.



Relevant Pages

  • Re: URGENT: Application_Start - doesnt fire
    ... It's as if the Web site simply ignores ANY ... > changes I make once the exception is encountered for the first time. ... You never said what the exception was. ... How can I get the Web server itself to ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cant see performance report, etc. SBS2003
    ... However, for "OpenSSH Server", you need to ensure it started, or set ... click to check the "Hide All Microsoft Services" ... Make sure no host header is assigned to the Default Web Site. ... Reinstall Monitoring component: ...
    (microsoft.public.windows.server.sbs)
  • Re: RPC over HTTPS fails following install of SharePoint Services
    ... I am also switching to a new server and on the new server I ... 80 so they get through firewalls OK but only the default web site has SSL ... and on the extra web site I am now running the sharepoint service and for now ... An unhandled exception has occurred. ...
    (microsoft.public.exchange.admin)
  • Re: ASP.NET Site Sending E-mail
    ... sending e-mail from the server when accessing the web site from a separate ... client computer. ... Server and client computers both in the same workgroup ... The local user on the client is also defined as a local user on the server ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: IIS (on SBS 2k) default website stopped address already in use
    ... server box properly and configure the following settings on the ISA server. ... Create an anonymous Site and Content rule for Windows Update ... Web site through a server that is running ISA Server ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)