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

Discussion in 'ASP .Net' started by rekaeps, May 4, 2006.

  1. rekaeps

    rekaeps Guest

    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 = "";
    string fromDisplayName = "Testing SendEmail";
    string toEmail = "";
    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.
    rekaeps, May 4, 2006
    #1
    1. Advertising

  2. rekaeps

    Jeff Dillon Guest

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

    I've never added code to specify "pickup location" and the rest. That is all
    configured generally in IIS Admin. Do you have a specific requirement to do
    it this way?

    Jeff
    "rekaeps" <> wrote in message
    news:eYn5%...
    > 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 = "";
    > string fromDisplayName = "Testing SendEmail";
    > string toEmail = "";
    > 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.
    >
    >
    >
    Jeff Dillon, May 4, 2006
    #2
    1. Advertising

  3. rekaeps

    rekaeps Guest

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

    No, we don't have a specific requirement to do it that way. I was simply
    trying all sorts of different things to try to get it to work. I initially
    tried without specifying the "pickup location" and the rest, but it wasn't
    working (it was throwing the exception). So, I started trying the other
    properties to see if I could get it to work. And, unfortunately, specifying
    the "pickup location" and the rest didn't work either--I still received the
    same exception.

    Any thoughts?



    "Jeff Dillon" <> wrote in message
    news:...
    > I've never added code to specify "pickup location" and the rest. That is

    all
    > configured generally in IIS Admin. Do you have a specific requirement to

    do
    > it this way?
    >
    > Jeff
    > "rekaeps" <> wrote in message
    > news:eYn5%...
    > > 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 = "";
    > > string fromDisplayName = "Testing SendEmail";
    > > string toEmail = "";
    > > 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.
    > >
    > >
    > >

    >
    >
    rekaeps, May 4, 2006
    #3
  4. rekaeps

    Jeff Dillon Guest

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

    Does it work when browsing from the same box?

    You might need Basic auth

    Jeff

    "rekaeps" <> wrote in message
    news:...
    > No, we don't have a specific requirement to do it that way. I was simply
    > trying all sorts of different things to try to get it to work. I
    > initially
    > tried without specifying the "pickup location" and the rest, but it wasn't
    > working (it was throwing the exception). So, I started trying the other
    > properties to see if I could get it to work. And, unfortunately,
    > specifying
    > the "pickup location" and the rest didn't work either--I still received
    > the
    > same exception.
    >
    > Any thoughts?
    >
    >
    >
    > "Jeff Dillon" <> wrote in message
    > news:...
    >> I've never added code to specify "pickup location" and the rest. That is

    > all
    >> configured generally in IIS Admin. Do you have a specific requirement to

    > do
    >> it this way?
    >>
    >> Jeff
    >> "rekaeps" <> wrote in message
    >> news:eYn5%...
    >> > 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 = "";
    >> > string fromDisplayName = "Testing SendEmail";
    >> > string toEmail = "";
    >> > 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.
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
    Jeff Dillon, May 4, 2006
    #4
  5. rekaeps

    rekaeps Guest

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

    Yes, it works when I browse from the same box (the server that is running
    IIS and the app.).



    "Jeff Dillon" <> wrote in message
    news:%...
    > Does it work when browsing from the same box?
    >
    > You might need Basic auth
    >
    > Jeff
    >
    > "rekaeps" <> wrote in message
    > news:...
    > > No, we don't have a specific requirement to do it that way. I was

    simply
    > > trying all sorts of different things to try to get it to work. I
    > > initially
    > > tried without specifying the "pickup location" and the rest, but it

    wasn't
    > > working (it was throwing the exception). So, I started trying the other
    > > properties to see if I could get it to work. And, unfortunately,
    > > specifying
    > > the "pickup location" and the rest didn't work either--I still received
    > > the
    > > same exception.
    > >
    > > Any thoughts?
    > >
    > >
    > >
    > > "Jeff Dillon" <> wrote in message
    > > news:...
    > >> I've never added code to specify "pickup location" and the rest. That

    is
    > > all
    > >> configured generally in IIS Admin. Do you have a specific requirement

    to
    > > do
    > >> it this way?
    > >>
    > >> Jeff
    > >> "rekaeps" <> wrote in message
    > >> news:eYn5%...
    > >> > 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 = "";
    > >> > string fromDisplayName = "Testing SendEmail";
    > >> > string toEmail = "";
    > >> > 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.
    > >> >
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
    rekaeps, May 4, 2006
    #5
  6. rekaeps

    rekaeps Guest

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

    Thanks Jeff for your suggestions. Since this is an intranet app., it is a
    requirement that we use Integrated Windows Authentication (can't use Basic
    auth).

    We're still having troubles, and this issue is quickly becoming high
    priority.

    Anyone have any suggestions/ideas?



    "rekaeps" <> wrote in message
    news:eYn5%...
    > 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 = "";
    > string fromDisplayName = "Testing SendEmail";
    > string toEmail = "";
    > 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.
    >
    >
    >
    rekaeps, May 4, 2006
    #6
  7. rekaeps

    Jeff Dillon Guest

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

    You can't use Integrated Auth from other machines! Unless you set up
    Kerberos, which is fairly involved.

    You'll need Basic. Try it and see

    Jeff

    "rekaeps" <> wrote in message
    news:...
    > Thanks Jeff for your suggestions. Since this is an intranet app., it is
    > a
    > requirement that we use Integrated Windows Authentication (can't use Basic
    > auth).
    >
    > We're still having troubles, and this issue is quickly becoming high
    > priority.
    >
    > Anyone have any suggestions/ideas?
    >
    >
    >
    > "rekaeps" <> wrote in message
    > news:eYn5%...
    >> 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 = "";
    >> string fromDisplayName = "Testing SendEmail";
    >> string toEmail = "";
    >> 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.
    >>
    >>
    >>

    >
    >
    Jeff Dillon, May 5, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henrik_the_boss
    Replies:
    0
    Views:
    2,630
    Henrik_the_boss
    Nov 5, 2003
  2. Replies:
    4
    Views:
    55,439
  3. =?Utf-8?B?VG9tIFdpbmdlcnQ=?=

    My.Log.Writeexception not writing to Application Event Log.

    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,354
    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=
    Jan 20, 2006
  4. Replies:
    0
    Views:
    1,334
  5. Tom Wingert
    Replies:
    0
    Views:
    320
    Tom Wingert
    Jan 12, 2006
Loading...

Share This Page