ASP.NET MailMessage in XP fails

F

Frank

Straightforward VB.NET 2002 code that works form both
Windows and ASP.NET apps on a Windows 2000 machine, and
works in the Windows app on a newly installed XP machine,
but fails in the ASP.NET code on XP. The unhandled
exception is "COMException: The 'SendUsing' configuration
value is invalid." If I handle the exception, the
exception's Message is "Could not access 'CDO.Message'
object."

The essence of the code is:
Imports System.Web.Mail
....
Dim m as New MailMessage()
m.From = ...set all properties
smtpmail.send(m)

There are no attachments, but adding attachments to any
of the 4 versions of the app does not change the results.
The smtp server is the local machine in all cases, and
changing that does not change the results.

I'd welcome any ideas.

Thanks.
 
R

Ray Dixon [MVP]

Hi Frank,

Does setting the SmtpServer property to "localhost" (or whatever your SMTP
server is) fix it? If not, try checking the ASPNET account's permissions on
the mailroot's folders.
 
F

Frank

Ray - thanks for responding - but, no, setting the
SmtpServer property to either "localhost" or another
available (working) smtp server does not change anything
for better or worse.

I also made the ASPNET account (aspnet_wp, right?) an
administrator. I've had some trouble before from folders
that didn't have web sharing turned on, so I did that for
the mailroot and its subfolders - no change.

The message, "Could not access 'CDO.Message' object", and
the fact that mail works fine from Windows Forms apps on
the same machine, makes it sound like it's an ASP.NET or
IIS issue.

There were also some Windows 2003 Server questions today
on the same topic, but none of the responses shed any
light on this for me.

Do you have any more suggestions?

Thanks. Frank
 
F

Frank

Jacky -

There is only one level of InnerException, "The server
rejected one or more recipient addresses. The server
response was: 550 5.7.1 Unable to relay for
(e-mail address removed)".

So my problem still is, why would the same code work from
a Windows app on this same (XP Pro) machine, and from
both Windows & asp.net on another machine?

Thanks.

Frank


-----Original Message-----



Could you use a debugger to trace into
the "InnerException" field of the
 
K

Kevin Spencer

The "Unable to relay" message would come if you used a server other than the
local machine, and that SMTP server disallows relaying. If you leave off the
SMTPServer property altogether, SMTPMail will use the local machine's SMTP
server by default. That's one way to make sure that the local machine's SMTP
server is used, and you shouldn't have any relaying issues in that case.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.
 
F

Frank

This solution came from Microsoft's Exchange group:

In earlier versions of Windows 2000, access to the local
SMTP server was automatically open to any computer that
tried to use it. In code, you did not need to specify
the SMTP server, and it would default to the local
machine and work.

Later in Win 2k, and in XP, 2003, etc, this was
tightened - you have to specifically give access to the
smtp server. In IIS, you go to the Properties of the
default smtp server, Access, Relay, and Add the local
computer IP address or name to the list.

And, in code, you must specify the smtpserver property.

It works, but re-opens the possibility that some
unauthorized outsider might use your machine to relay
messages.

Frank
 
Y

Yan-Hong Huang[MSFT]

Hello Frank,

Thanks for sharing it with us. I believe it could help web email programmers much in this group.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Frank" <[email protected]>
!Sender: "Frank" <[email protected]>
!References: <[email protected]> <uqb#[email protected]>
<[email protected]>
!Subject: Re: ASP.NET MailMessage in XP fails
!Date: Wed, 30 Jul 2003 11:20:32 -0700
!Lines: 110
!Message-ID: <[email protected]>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNWx0NEjufaGK23R/aVA5UkFC7z0Q==
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:163483
!NNTP-Posting-Host: TK2MSFTNGXA06 10.40.1.53
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!This solution came from Microsoft's Exchange group:
!
!In earlier versions of Windows 2000, access to the local
!SMTP server was automatically open to any computer that
!tried to use it. In code, you did not need to specify
!the SMTP server, and it would default to the local
!machine and work.
!
!Later in Win 2k, and in XP, 2003, etc, this was
!tightened - you have to specifically give access to the
!smtp server. In IIS, you go to the Properties of the
!default smtp server, Access, Relay, and Add the local
!computer IP address or name to the list.
!
!And, in code, you must specify the smtpserver property.
!
!It works, but re-opens the possibility that some
!unauthorized outsider might use your machine to relay
!messages.
!
!Frank
!
!
!
!
!>-----Original Message-----
!>Ray - thanks for responding - but, no, setting the
!>SmtpServer property to either "localhost" or another
!>available (working) smtp server does not change anything
!>for better or worse.
!>
!>I also made the ASPNET account (aspnet_wp, right?) an
!>administrator. I've had some trouble before from
!folders
!>that didn't have web sharing turned on, so I did that
!for
!>the mailroot and its subfolders - no change.
!>
!>The message, "Could not access 'CDO.Message' object",
!and
!>the fact that mail works fine from Windows Forms apps on
!>the same machine, makes it sound like it's an ASP.NET or
!>IIS issue.
!>
!>There were also some Windows 2003 Server questions today
!>on the same topic, but none of the responses shed any
!>light on this for me.
!>
!>Do you have any more suggestions?
!>
!>Thanks. Frank
!>
!>
!>
!>
!>
!>>-----Original Message-----
!>>Hi Frank,
!>>
!>>Does setting the SmtpServer property to "localhost" (or
!>whatever your SMTP
!>>server is) fix it? If not, try checking the ASPNET
!>account's permissions on
!>>the mailroot's folders.
!>>
!>>
!>>--
!>>Ray Dixon - Microsoft MVP
!>>[email protected]
!>>(remove NOSPAM. from my e-mail address for a direct
!>reply)
!>>
!>>
!>>!>>> Straightforward VB.NET 2002 code that works form both
!>>> Windows and ASP.NET apps on a Windows 2000 machine,
!and
!>>> works in the Windows app on a newly installed XP
!>machine,
!>>> but fails in the ASP.NET code on XP. The unhandled
!>>> exception is "COMException: The 'SendUsing'
!>configuration
!>>> value is invalid." If I handle the exception, the
!>>> exception's Message is "Could not access 'CDO.Message'
!>>> object."
!>>>
!>>> The essence of the code is:
!>>> Imports System.Web.Mail
!>>> ...
!>>> Dim m as New MailMessage()
!>>> m.From = ...set all properties
!>>> smtpmail.send(m)
!>>>
!>>> There are no attachments, but adding attachments to
!any
!>>> of the 4 versions of the app does not change the
!>results.
!>>> The smtp server is the local machine in all cases, and
!>>> changing that does not change the results.
!>>>
!>>> I'd welcome any ideas.
!>>>
!>>> Thanks.
!>>
!>>
!>>.
!>>
!>.
!>
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top