By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

ASP.NET Site Sending E-mail

P: n/a
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.

Here's some details:

Server and client computers both in the same workgroup
Logged into server as local Administrator
Logged into client as a local user that is only in the Users group on the
client computer
The local user on the client 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
Client 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>

..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.

Basically, this is supposed to be an exception notification thing.
What's wrong? Am I missing something? How can I make the above scenario
work?
Thanks.

May 5 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Or, set the application pool/IUSR account to run as a domain account

Jeff

"dnuos" <no****@company.com> wrote in message
news:%2****************@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.

Here's some details:

Server and client computers both in the same workgroup
Logged into server as local Administrator
Logged into client as a local user that is only in the Users group on the
client computer
The local user on the client 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
Client 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>

.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.

Basically, this is supposed to be an exception notification thing.
What's wrong? Am I missing something? How can I make the above scenario
work?
Thanks.

May 5 '06 #2

P: n/a
You need to turn on Basic authentication. If you want it secure, then HTTPS
with Basic. Otherwise, Kerberos.

Jeff

"dnuos" <no****@company.com> wrote in message
news:%2****************@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.

Here's some details:

Server and client computers both in the same workgroup
Logged into server as local Administrator
Logged into client as a local user that is only in the Users group on the
client computer
The local user on the client 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
Client 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>

.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.

Basically, this is supposed to be an exception notification thing.
What's wrong? Am I missing something? How can I make the above scenario
work?
Thanks.

May 5 '06 #3

P: n/a
"dnuos" <no****@company.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
What's wrong? Am I missing something? How can I make the above scenario
work?


http://www.systemnetmail.com
May 5 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.