473,372 Members | 1,062 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

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 = "do********@testingsendemail.com";
string fromDisplayName = "Testing SendEmail";
string toEmail = "pe****@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.

May 4 '06 #1
6 2499
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" <no****@company.com> wrote in message
news:eY****************@TK2MSFTNGP05.phx.gbl...
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 = "do********@testingsendemail.com";
string fromDisplayName = "Testing SendEmail";
string toEmail = "pe****@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.

May 4 '06 #2
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" <je********@hotmail.com> wrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
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" <no****@company.com> wrote in message
news:eY****************@TK2MSFTNGP05.phx.gbl...
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 = "do********@testingsendemail.com";
string fromDisplayName = "Testing SendEmail";
string toEmail = "pe****@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.


May 4 '06 #3
Does it work when browsing from the same box?

You might need Basic auth

Jeff

"rekaeps" <no****@company.com> wrote in message
news:ek**************@TK2MSFTNGP05.phx.gbl...
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" <je********@hotmail.com> wrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
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" <no****@company.com> wrote in message
news:eY****************@TK2MSFTNGP05.phx.gbl...
> 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 = "do********@testingsendemail.com";
> string fromDisplayName = "Testing SendEmail";
> string toEmail = "pe****@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.
>
>
>



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

"Jeff Dillon" <je********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Does it work when browsing from the same box?

You might need Basic auth

Jeff

"rekaeps" <no****@company.com> wrote in message
news:ek**************@TK2MSFTNGP05.phx.gbl...
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" <je********@hotmail.com> wrote in message
news:Ov**************@TK2MSFTNGP03.phx.gbl...
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" <no****@company.com> wrote in message
news:eY****************@TK2MSFTNGP05.phx.gbl...
> 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 = "do********@testingsendemail.com";
> string fromDisplayName = "Testing SendEmail";
> string toEmail = "pe****@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.
>
>
>



May 4 '06 #5
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" <no****@company.com> wrote in message
news:eY****************@TK2MSFTNGP05.phx.gbl...
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 = "do********@testingsendemail.com";
string fromDisplayName = "Testing SendEmail";
string toEmail = "pe****@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.

May 4 '06 #6
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" <no****@company.com> wrote in message
news:eM**************@TK2MSFTNGP04.phx.gbl...
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" <no****@company.com> wrote in message
news:eY****************@TK2MSFTNGP05.phx.gbl...
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 = "do********@testingsendemail.com";
string fromDisplayName = "Testing SendEmail";
string toEmail = "pe****@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.


May 5 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Butch | last post by:
Hi, I won't lie to you. I'm trying to get data from html source from a 3rd party website. I'm NOT interested in stealing code,hacking,sending spam or anything sinister like that. I just want the...
2
by: HS Hartkamp | last post by:
Hello, Over the past 8 years, I have created an application for a scouting camp site in the Netherlands. With this application, we keep track of all groups camping on our site, number of...
3
by: Eref DURNA | last post by:
My Aim is to make a windows application download which support session and cookies. There is a web site which gives images as links like this...
0
by: Kyle | last post by:
I have a project "wyatterp.com" that was built to be an ERP development library using postgresql as a backend. We use it internally to run a 120 employee manufacturing company. And it does...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
2
by: Sean | last post by:
I am trying to read a cookie I set but I am not sure if I really set it correctly or I am not reading it correctly. I was given the following instructions to set the cookie. It appears to be...
0
by: david220 | last post by:
hi once members sign up to my site they get sent an email which contains there username/password which they enter on a sign up form. Once they've signed up the email is automatically sent using...
2
by: erbilkonuk | last post by:
Hi everyone, I have been developing a project that is composed of one windows service and one ASP.NET web site. The windows service and ASP.NET web site reside on the same server. I want to send...
3
by: Brad | last post by:
I have an aspx page that is sending pdf files to client browsers: it uses a filestream to read the pdf file and response.binarywrite to send content to the browser. This has worked great for years...
5
by: Tony M | last post by:
vs 2005 - vb .net (desktop app) - XP Pro Trying to manipulate data form a desktop app. to a remote hosted website? Just trying to connect for now. Anyone know what I can change to make...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.