473,387 Members | 1,512 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,387 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
0 1071

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: Eþref 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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.