Connecting Tech Pros Worldwide Help | Site Map

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

rekaeps
Guest
 
Posts: n/a
#1: May 4 '06
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@testingsendemail.com";
string fromDisplayName = "Testing SendEmail";
string toEmail = "person@company.com";
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.PickupDirectory FromIis;

// 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
Guest
 
Posts: n/a
#2: May 4 '06

re: HELP: 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" <nospam@company.com> wrote in message
news:eYn5%23e5bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=blue]
> 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@testingsendemail.com";
> string fromDisplayName = "Testing SendEmail";
> string toEmail = "person@company.com";
> 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.PickupDirectory FromIis;
>
> // 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.
>
>
>[/color]


rekaeps
Guest
 
Posts: n/a
#3: May 4 '06

re: HELP: 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" <jeffdillon@hotmail.com> wrote in message
news:OvzlYy5bGHA.3484@TK2MSFTNGP03.phx.gbl...[color=blue]
> I've never added code to specify "pickup location" and the rest. That is[/color]
all[color=blue]
> configured generally in IIS Admin. Do you have a specific requirement to[/color]
do[color=blue]
> it this way?
>
> Jeff
> "rekaeps" <nospam@company.com> wrote in message
> news:eYn5%23e5bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=green]
> > We are developing an ASP.NET 2.0 (C#) application, and I'm having[/color][/color]
troubles[color=blue][color=green]
> > sending e-mail from the server when accessing the web site from a[/color][/color]
separate[color=blue][color=green]
> > 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[/color][/color]
on[color=blue][color=green]
> > 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[/color][/color]
site[color=blue][color=green]
> >
> >
> > 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@testingsendemail.com";
> > string fromDisplayName = "Testing SendEmail";
> > string toEmail = "person@company.com";
> > 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.PickupDirectory FromIis;
> >
> > // 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 =[/color][/color]
@"C:\Inetpub\mailroot\Pickup";[color=blue][color=green]
> >
> > // 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[/color][/color]
it[color=blue][color=green]
> > 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[/color][/color]
server[color=blue][color=green]
> > for the session started by the client in the scenario described above,[/color][/color]
it[color=blue][color=green]
> > 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[/color][/color]
is[color=blue][color=green]
> > denied (Cannot open log for source 'Application'. You may not have[/color][/color]
write[color=blue][color=green]
> > 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[/color][/color]
log[color=blue][color=green]
> > on
> > the server for the session started by the client in the scenario[/color][/color]
described[color=blue][color=green]
> > 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.
> >
> >
> >[/color]
>
>[/color]


Jeff Dillon
Guest
 
Posts: n/a
#4: May 4 '06

re: HELP: 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" <nospam@company.com> wrote in message
news:ekHuD76bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=blue]
> 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" <jeffdillon@hotmail.com> wrote in message
> news:OvzlYy5bGHA.3484@TK2MSFTNGP03.phx.gbl...[color=green]
>> I've never added code to specify "pickup location" and the rest. That is[/color]
> all[color=green]
>> configured generally in IIS Admin. Do you have a specific requirement to[/color]
> do[color=green]
>> it this way?
>>
>> Jeff
>> "rekaeps" <nospam@company.com> wrote in message
>> news:eYn5%23e5bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=darkred]
>> > We are developing an ASP.NET 2.0 (C#) application, and I'm having[/color][/color]
> troubles[color=green][color=darkred]
>> > sending e-mail from the server when accessing the web site from a[/color][/color]
> separate[color=green][color=darkred]
>> > 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[/color][/color]
> on[color=green][color=darkred]
>> > 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[/color][/color]
> site[color=green][color=darkred]
>> >
>> >
>> > 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@testingsendemail.com";
>> > string fromDisplayName = "Testing SendEmail";
>> > string toEmail = "person@company.com";
>> > 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.PickupDirectory FromIis;
>> >
>> > // 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 =[/color][/color]
> @"C:\Inetpub\mailroot\Pickup";[color=green][color=darkred]
>> >
>> > // 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[/color][/color]
> it[color=green][color=darkred]
>> > 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[/color][/color]
> server[color=green][color=darkred]
>> > for the session started by the client in the scenario described above,[/color][/color]
> it[color=green][color=darkred]
>> > 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[/color][/color]
> is[color=green][color=darkred]
>> > denied (Cannot open log for source 'Application'. You may not have[/color][/color]
> write[color=green][color=darkred]
>> > 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[/color][/color]
> log[color=green][color=darkred]
>> > on
>> > the server for the session started by the client in the scenario[/color][/color]
> described[color=green][color=darkred]
>> > 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.
>> >
>> >
>> >[/color]
>>
>>[/color]
>
>[/color]


rekaeps
Guest
 
Posts: n/a
#5: May 4 '06

re: HELP: 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" <jeffdillon@hotmail.com> wrote in message
news:%23p2gXN7bGHA.3388@TK2MSFTNGP05.phx.gbl...[color=blue]
> Does it work when browsing from the same box?
>
> You might need Basic auth
>
> Jeff
>
> "rekaeps" <nospam@company.com> wrote in message
> news:ekHuD76bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=green]
> > No, we don't have a specific requirement to do it that way. I was[/color][/color]
simply[color=blue][color=green]
> > 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[/color][/color]
wasn't[color=blue][color=green]
> > 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" <jeffdillon@hotmail.com> wrote in message
> > news:OvzlYy5bGHA.3484@TK2MSFTNGP03.phx.gbl...[color=darkred]
> >> I've never added code to specify "pickup location" and the rest. That[/color][/color][/color]
is[color=blue][color=green]
> > all[color=darkred]
> >> configured generally in IIS Admin. Do you have a specific requirement[/color][/color][/color]
to[color=blue][color=green]
> > do[color=darkred]
> >> it this way?
> >>
> >> Jeff
> >> "rekaeps" <nospam@company.com> wrote in message
> >> news:eYn5%23e5bGHA.1960@TK2MSFTNGP05.phx.gbl...
> >> > We are developing an ASP.NET 2.0 (C#) application, and I'm having[/color]
> > troubles[color=darkred]
> >> > sending e-mail from the server when accessing the web site from a[/color]
> > separate[color=darkred]
> >> > 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[/color][/color][/color]
group[color=blue][color=green]
> > on[color=darkred]
> >> > 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[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> >> > 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[/color]
> > site[color=darkred]
> >> >
> >> >
> >> > 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@testingsendemail.com";
> >> > string fromDisplayName = "Testing SendEmail";
> >> > string toEmail = "person@company.com";
> >> > 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.PickupDirectory FromIis;
> >> >
> >> > // 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 =[/color]
> > @"C:\Inetpub\mailroot\Pickup";[color=darkred]
> >> >
> >> > // For smtpclient.Port, I've tried not setting it and I've[/color][/color][/color]
tried[color=blue][color=green][color=darkred]
> >> > explicitly setting it to 25
> >> > // neither of these work
> >> > smtpclient.Port = 25;
> >> >
> >> > // For smtpclient.UseDefaultCredentials, I've tried not[/color][/color][/color]
setting[color=blue][color=green]
> > it[color=darkred]
> >> > 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[/color]
> > server[color=darkred]
> >> > for the session started by the client in the scenario described[/color][/color][/color]
above,[color=blue][color=green]
> > it[color=darkred]
> >> > 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:[/color][/color][/color]
Access[color=blue][color=green]
> > is[color=darkred]
> >> > denied (Cannot open log for source 'Application'. You may not have[/color]
> > write[color=darkred]
> >> > 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[/color]
> > log[color=darkred]
> >> > on
> >> > the server for the session started by the client in the scenario[/color]
> > described[color=darkred]
> >> > 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.
> >> >
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]


rekaeps
Guest
 
Posts: n/a
#6: May 5 '06

re: HELP: 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" <nospam@company.com> wrote in message
news:eYn5%23e5bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=blue]
> 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[/color]
to[color=blue]
> 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@testingsendemail.com";
> string fromDisplayName = "Testing SendEmail";
> string toEmail = "person@company.com";
> 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.PickupDirectory FromIis;
>
> // 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[/color]
it[color=blue]
> and I've tried
> // explicitly setting the path to the IIS pickup folder
> // neither of these work
> smtpclient.PickupDirectoryLocation =[/color]
@"C:\Inetpub\mailroot\Pickup";[color=blue]
>
> // 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[/color]
without[color=blue]
> 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[/color]
System.Diagnostics.EventLog();[color=blue]
> 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[/color]
whatever[color=blue]
> without any problems. But, when the site tries to write to the event log[/color]
on[color=blue]
> 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.
>
>
>[/color]


Jeff Dillon
Guest
 
Posts: n/a
#7: May 5 '06

re: HELP: 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" <nospam@company.com> wrote in message
news:eMlQ7z8bGHA.3380@TK2MSFTNGP04.phx.gbl...[color=blue]
> 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" <nospam@company.com> wrote in message
> news:eYn5%23e5bGHA.1960@TK2MSFTNGP05.phx.gbl...[color=green]
>> 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[/color]
> to[color=green]
>> 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@testingsendemail.com";
>> string fromDisplayName = "Testing SendEmail";
>> string toEmail = "person@company.com";
>> 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.PickupDirectory FromIis;
>>
>> // 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[/color]
> it[color=green]
>> and I've tried
>> // explicitly setting the path to the IIS pickup folder
>> // neither of these work
>> smtpclient.PickupDirectoryLocation =[/color]
> @"C:\Inetpub\mailroot\Pickup";[color=green]
>>
>> // 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[/color]
> without[color=green]
>> 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[/color]
> System.Diagnostics.EventLog();[color=green]
>> 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[/color]
> whatever[color=green]
>> without any problems. But, when the site tries to write to the event log[/color]
> on[color=green]
>> 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.
>>
>>
>>[/color]
>
>[/color]


Closed Thread