apsnet_wp.exe non-default identity vs. System.Web.Mail.SmtpMail

  • Thread starter Thread starter Andrei Suvorov
  • Start date Start date
A

Andrei Suvorov

Hello,

Can anyone suggest how to handle th following problem:

1. I've changed userName and password attributes in <processModel> in
machine.config to make aspnet_wp.exe run under my local account.
2. But now the following code in my .aspx fails with exception:

using System.Web.Mail;

SmtpMail.SmtpServer = "mymailhost";
SmtpMail.Send("(e-mail address removed)", "(e-mail address removed)","test 2", "test message");

Exception:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport
failed to connect to the server.

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.CdoSysHelper.Send(String from, String to, String
subject, String messageText)
at System.Web.Mail.SmtpMail.Send(String from, String to, String subject,
String messageText)
at TestMail1._Default.ButtonSend_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testmail1\default.aspx.cs:line 54

Any suggestions would be thankfully appreciated.

Regards,
Andrei Suvorov.
 
Now I'm certain about conditions up which this problem occurs and not:

1. No problem. SmtpMail.SmtpServer = "mymailhost" and username/pasword under
<processModel> are default (ASPNET account).
2. Problem.. SmtpMail.SmtpServer = "mymailhost" and username/pasword under
<processModel> are set to non-default (set to local or domain user).
3.No Problem.. SmtpMail.SmtpServer = "" and username/pasword under
<processModel> are set to non-default (set to local or domain user). The
email gets sent only when local IIS SMTP is running.

Can anyone suggest how to make the #2 working? I really need to use
non-local SMTP host for email delivery.

Thanks in advance,
Andrei Suvorov.
 
You will probably need to go into the SMTP Server management console. Go to
the IIS MMC snap in (ie. Start -> Program -> administrative tools ->
Internet Information Services), expand the nodes and look for "Default SMTP
Virtual Server".
Right click and select properties, choose the "Access" tab and have a look
at the "authentication" settings to make sure they will allow your
particular user to send mail.

HTH

--
- Paul Glavich
Microsoft MVP - ASP.NET


Andrei Suvorov said:
Now I'm certain about conditions up which this problem occurs and not:

1. No problem. SmtpMail.SmtpServer = "mymailhost" and username/pasword under
<processModel> are default (ASPNET account).
2. Problem.. SmtpMail.SmtpServer = "mymailhost" and username/pasword under
<processModel> are set to non-default (set to local or domain user).
3.No Problem.. SmtpMail.SmtpServer = "" and username/pasword under
<processModel> are set to non-default (set to local or domain user). The
email gets sent only when local IIS SMTP is running.

Can anyone suggest how to make the #2 working? I really need to use
non-local SMTP host for email delivery.

Thanks in advance,
Andrei Suvorov.



Andrei Suvorov said:
Hello,

Can anyone suggest how to handle th following problem:

1. I've changed userName and password attributes in <processModel> in
machine.config to make aspnet_wp.exe run under my local account.
2. But now the following code in my .aspx fails with exception:

using System.Web.Mail;

SmtpMail.SmtpServer = "mymailhost";
SmtpMail.Send("(e-mail address removed)", "(e-mail address removed)","test 2", "test message");

Exception:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport
failed to connect to the server.

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.CdoSysHelper.Send(String from, String to, String
subject, String messageText)
at System.Web.Mail.SmtpMail.Send(String from, String to, String subject,
String messageText)
at TestMail1._Default.ButtonSend_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testmail1\default.aspx.cs:line 54

Any suggestions would be thankfully appreciated.

Regards,
Andrei Suvorov.
 
I've checked - there are default settings. For example, anonymous access is
allowed.

Paul Glavich said:
You will probably need to go into the SMTP Server management console. Go to
the IIS MMC snap in (ie. Start -> Program -> administrative tools ->
Internet Information Services), expand the nodes and look for "Default SMTP
Virtual Server".
Right click and select properties, choose the "Access" tab and have a look
at the "authentication" settings to make sure they will allow your
particular user to send mail.

HTH

--
- Paul Glavich
Microsoft MVP - ASP.NET


Andrei Suvorov said:
Now I'm certain about conditions up which this problem occurs and not:

1. No problem. SmtpMail.SmtpServer = "mymailhost" and username/pasword under
<processModel> are default (ASPNET account).
2. Problem.. SmtpMail.SmtpServer = "mymailhost" and username/pasword under
<processModel> are set to non-default (set to local or domain user).
3.No Problem.. SmtpMail.SmtpServer = "" and username/pasword under
<processModel> are set to non-default (set to local or domain user). The
email gets sent only when local IIS SMTP is running.

Can anyone suggest how to make the #2 working? I really need to use
non-local SMTP host for email delivery.

Thanks in advance,
Andrei Suvorov.



Andrei Suvorov said:
Hello,

Can anyone suggest how to handle th following problem:

1. I've changed userName and password attributes in <processModel> in
machine.config to make aspnet_wp.exe run under my local account.
2. But now the following code in my .aspx fails with exception:

using System.Web.Mail;

SmtpMail.SmtpServer = "mymailhost";
SmtpMail.Send("(e-mail address removed)", "(e-mail address removed)","test 2", "test message");

Exception:
System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x80040213): The transport
failed to connect to the server.

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.CdoSysHelper.Send(String from, String to, String
subject, String messageText)
at System.Web.Mail.SmtpMail.Send(String from, String to, String subject,
String messageText)
at TestMail1._Default.ButtonSend_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\testmail1\default.aspx.cs:line 54

Any suggestions would be thankfully appreciated.

Regards,
Andrei Suvorov.
 
What about your "Allowed to Relay" settings?

Cheers
Ken

: I've checked - there are default settings. For example, anonymous access
is
: allowed.
:
: message : > You will probably need to go into the SMTP Server management console. Go
: to
: > the IIS MMC snap in (ie. Start -> Program -> administrative tools ->
: > Internet Information Services), expand the nodes and look for "Default
: SMTP
: > Virtual Server".
: > Right click and select properties, choose the "Access" tab and have a
look
: > at the "authentication" settings to make sure they will allow your
: > particular user to send mail.
: >
: > HTH
: >
: > --
: > - Paul Glavich
: > Microsoft MVP - ASP.NET
: >
: >
: > : > > Now I'm certain about conditions up which this problem occurs and not:
: > >
: > > 1. No problem. SmtpMail.SmtpServer = "mymailhost" and username/pasword
: > under
: > > <processModel> are default (ASPNET account).
: > > 2. Problem.. SmtpMail.SmtpServer = "mymailhost" and username/pasword
: under
: > > <processModel> are set to non-default (set to local or domain user).
: > > 3.No Problem.. SmtpMail.SmtpServer = "" and username/pasword under
: > > <processModel> are set to non-default (set to local or domain user).
The
: > > email gets sent only when local IIS SMTP is running.
: > >
: > > Can anyone suggest how to make the #2 working? I really need to use
: > > non-local SMTP host for email delivery.
: > >
: > > Thanks in advance,
: > > Andrei Suvorov.
: > >
: > >
: > >
: > > : > > > Hello,
: > > >
: > > > Can anyone suggest how to handle th following problem:
: > > >
: > > > 1. I've changed userName and password attributes in <processModel>
in
: > > > machine.config to make aspnet_wp.exe run under my local account.
: > > > 2. But now the following code in my .aspx fails with exception:
: > > >
: > > > using System.Web.Mail;
: > > >
: > > > SmtpMail.SmtpServer = "mymailhost";
: > > > SmtpMail.Send("(e-mail address removed)", "(e-mail address removed)","test 2", "test
: message");
: > > >
: > > > Exception:
: > > > System.Web.HttpException: Could not access 'CDO.Message'
object. --->
: > > > System.Reflection.TargetInvocationException: Exception has been
thrown
: > by
: > > > the target of an invocation. --->
: > > > System.Runtime.InteropServices.COMException (0x80040213): The
: transport
: > > > failed to connect to the server.
: > > >
: > > > --- End of inner exception stack trace ---
: > > > at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
: > > > invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
: > Int32
: > > > culture, String[] namedParameters)
: > > > at System.RuntimeType.InvokeMember(String name, BindingFlags
: > > invokeAttr,
: > > > Binder binder, Object target, Object[] args, ParameterModifier[]
: > > modifiers,
: > > > CultureInfo culture, String[] namedParameters)
: > > > at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
: > > Binder
: > > > binder, Object target, Object[] args)
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type,
: Object
: > > > obj, String methodName, Object[] args)
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
: > String
: > > > methodName, Object[] args)
: > > > --- End of inner exception stack trace ---
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
: > String
: > > > methodName, Object[] args)
: > > > at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
: > > > at System.Web.Mail.CdoSysHelper.Send(String from, String to,
String
: > > > subject, String messageText)
: > > > at System.Web.Mail.SmtpMail.Send(String from, String to, String
: > > subject,
: > > > String messageText)
: > > > at TestMail1._Default.ButtonSend_Click(Object sender, EventArgs
e)
: in
: > > > c:\inetpub\wwwroot\testmail1\default.aspx.cs:line 54
: > > >
: > > > Any suggestions would be thankfully appreciated.
: > > >
: > > > Regards,
: > > > Andrei Suvorov.
: > > >
: > > >
: > >
: > >
: >
: >
:
:
 
I checked - all users are allowed to relay, but the problem still there.

Ken Schaefer said:
What about your "Allowed to Relay" settings?

Cheers
Ken

: I've checked - there are default settings. For example, anonymous access
is
: allowed.
:
: message : > You will probably need to go into the SMTP Server management console. Go
: to
: > the IIS MMC snap in (ie. Start -> Program -> administrative tools ->
: > Internet Information Services), expand the nodes and look for "Default
: SMTP
: > Virtual Server".
: > Right click and select properties, choose the "Access" tab and have a
look
: > at the "authentication" settings to make sure they will allow your
: > particular user to send mail.
: >
: > HTH
: >
: > --
: > - Paul Glavich
: > Microsoft MVP - ASP.NET
: >
: >
: > : > > Now I'm certain about conditions up which this problem occurs and not:
: > >
: > > 1. No problem. SmtpMail.SmtpServer = "mymailhost" and username/pasword
: > under
: > > <processModel> are default (ASPNET account).
: > > 2. Problem.. SmtpMail.SmtpServer = "mymailhost" and username/pasword
: under
: > > <processModel> are set to non-default (set to local or domain user).
: > > 3.No Problem.. SmtpMail.SmtpServer = "" and username/pasword under
: > > <processModel> are set to non-default (set to local or domain user).
The
: > > email gets sent only when local IIS SMTP is running.
: > >
: > > Can anyone suggest how to make the #2 working? I really need to use
: > > non-local SMTP host for email delivery.
: > >
: > > Thanks in advance,
: > > Andrei Suvorov.
: > >
: > >
: > >
: > > : > > > Hello,
: > > >
: > > > Can anyone suggest how to handle th following problem:
: > > >
: > > > 1. I've changed userName and password attributes in <processModel>
in
: > > > machine.config to make aspnet_wp.exe run under my local account.
: > > > 2. But now the following code in my .aspx fails with exception:
: > > >
: > > > using System.Web.Mail;
: > > >
: > > > SmtpMail.SmtpServer = "mymailhost";
: > > > SmtpMail.Send("(e-mail address removed)", "(e-mail address removed)","test 2", "test
: message");
: > > >
: > > > Exception:
: > > > System.Web.HttpException: Could not access 'CDO.Message'
object. --->
: > > > System.Reflection.TargetInvocationException: Exception has been
thrown
: > by
: > > > the target of an invocation. --->
: > > > System.Runtime.InteropServices.COMException (0x80040213): The
: transport
: > > > failed to connect to the server.
: > > >
: > > > --- End of inner exception stack trace ---
: > > > at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
: > > > invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
: > Int32
: > > > culture, String[] namedParameters)
: > > > at System.RuntimeType.InvokeMember(String name, BindingFlags
: > > invokeAttr,
: > > > Binder binder, Object target, Object[] args, ParameterModifier[]
: > > modifiers,
: > > > CultureInfo culture, String[] namedParameters)
: > > > at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
: > > Binder
: > > > binder, Object target, Object[] args)
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type,
: Object
: > > > obj, String methodName, Object[] args)
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
: > String
: > > > methodName, Object[] args)
: > > > --- End of inner exception stack trace ---
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
: > String
: > > > methodName, Object[] args)
: > > > at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
: > > > at System.Web.Mail.CdoSysHelper.Send(String from, String to,
String
: > > > subject, String messageText)
: > > > at System.Web.Mail.SmtpMail.Send(String from, String to, String
: > > subject,
: > > > String messageText)
: > > > at TestMail1._Default.ButtonSend_Click(Object sender, EventArgs
e)
: in
: > > > c:\inetpub\wwwroot\testmail1\default.aspx.cs:line 54
: > > >
: > > > Any suggestions would be thankfully appreciated.
: > > >
: > > > Regards,
: > > > Andrei Suvorov.
: > > >
: > > >
: > >
: > >
: >
: >
:
:
 
Perhaps compare the group and security restrictions on the account you are
trying to use. Maybe it is not allowed to run as a service (or something
similar) in your local security policy which is preventing it from working.
--
- Paul Glavich
Microsoft MVP - ASP.NET


Andrei Suvorov said:
I checked - all users are allowed to relay, but the problem still there.

Ken Schaefer said:
What about your "Allowed to Relay" settings?

Cheers
Ken

: I've checked - there are default settings. For example, anonymous access
is
: allowed.
:
: message : > You will probably need to go into the SMTP Server management
console.
Go
: to
: > the IIS MMC snap in (ie. Start -> Program -> administrative tools ->
: > Internet Information Services), expand the nodes and look for "Default
: SMTP
: > Virtual Server".
: > Right click and select properties, choose the "Access" tab and have a
look
: > at the "authentication" settings to make sure they will allow your
: > particular user to send mail.
: >
: > HTH
: >
: > --
: > - Paul Glavich
: > Microsoft MVP - ASP.NET
: >
: >
: > : > > Now I'm certain about conditions up which this problem occurs and not:
: > >
: > > 1. No problem. SmtpMail.SmtpServer = "mymailhost" and username/pasword
: > under
: > > <processModel> are default (ASPNET account).
: > > 2. Problem.. SmtpMail.SmtpServer = "mymailhost" and username/pasword
: under
: > > <processModel> are set to non-default (set to local or domain user).
: > > 3.No Problem.. SmtpMail.SmtpServer = "" and username/pasword under
: > > <processModel> are set to non-default (set to local or domain user).
The
: > > email gets sent only when local IIS SMTP is running.
: > >
: > > Can anyone suggest how to make the #2 working? I really need to use
: > > non-local SMTP host for email delivery.
: > >
: > > Thanks in advance,
: > > Andrei Suvorov.
: > >
: > >
: > >
: > > : > > > Hello,
: > > >
: > > > Can anyone suggest how to handle th following problem:
: > > >
: > > > 1. I've changed userName and password attributes in
in
: > > > machine.config to make aspnet_wp.exe run under my local account.
: > > > 2. But now the following code in my .aspx fails with exception:
: > > >
: > > > using System.Web.Mail;
: > > >
: > > > SmtpMail.SmtpServer = "mymailhost";
: > > > SmtpMail.Send("(e-mail address removed)", "(e-mail address removed)","test 2", "test
: message");
: > > >
: > > > Exception:
: > > > System.Web.HttpException: Could not access 'CDO.Message'
object. --->
: > > > System.Reflection.TargetInvocationException: Exception has been
thrown
: > by
: > > > the target of an invocation. --->
: > > > System.Runtime.InteropServices.COMException (0x80040213): The
: transport
: > > > failed to connect to the server.
: > > >
: > > > --- End of inner exception stack trace ---
: > > > at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
: > > > invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
: > Int32
: > > > culture, String[] namedParameters)
: > > > at System.RuntimeType.InvokeMember(String name, BindingFlags
: > > invokeAttr,
: > > > Binder binder, Object target, Object[] args, ParameterModifier[]
: > > modifiers,
: > > > CultureInfo culture, String[] namedParameters)
: > > > at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
: > > Binder
: > > > binder, Object target, Object[] args)
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type,
: Object
: > > > obj, String methodName, Object[] args)
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
: > String
: > > > methodName, Object[] args)
: > > > --- End of inner exception stack trace ---
: > > > at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
: > String
: > > > methodName, Object[] args)
: > > > at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
: > > > at System.Web.Mail.CdoSysHelper.Send(String from, String to,
String
: > > > subject, String messageText)
: > > > at System.Web.Mail.SmtpMail.Send(String from, String to, String
: > > subject,
: > > > String messageText)
: > > > at TestMail1._Default.ButtonSend_Click(Object sender, EventArgs
e)
: in
: > > > c:\inetpub\wwwroot\testmail1\default.aspx.cs:line 54
: > > >
: > > > Any suggestions would be thankfully appreciated.
: > > >
: > > > Regards,
: > > > Andrei Suvorov.
: > > >
: > > >
: > >
: > >
: >
: >
:
:
 
Back
Top