Can't access CDO.Message

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have a windows form application that I am trying to send
mail from. Currently I have an ASP.net web application
running that uses the same System.web.mail.mailmessage
class, and the same smptp server which works fine. When
trying to do the exact same thing from a windows form I
get an error saying that it could not access the
CDO.Message object.

Why would there be a difference? How do I fix?
 
Hello Chris,

I think it is related with security setting of ASPNET account. The ASPNET
account needs to have sufficient permission to access a component and any
other resource that it requires. Please try the steps below to grant the
ASPNET the property permission.

1. Start -> Control Panel -> Administrative Tools -> Component Services.
2. Look for the desired COM component and add the ASPNET'user to the roles.

Alternatively, you can launch the aspnet_wp.exe with an account which has
enough permission. Please try these steps:

1. Find machine.config (usually under <windows
directory>\Microsoft.NET\Framework\v1.0.3705\CONFIG) and edit the
<processmodel> section. Change the "userName" attribute value to "SYSTEM".

2. Edit the "web.config" file in the ASP .NET project. Add the following
line:
<identity impersonate="true" userName=<your user name> password=<your
password> />

The user name you provide here need to have the permission to call the CDO
component.

3. Restart the aspnet_wp.exe. You can also kill it in Task Manager. Then
aspnet_wp will start using SYSTEM account.

You also can impersonate ASPNET as a user having permission. For more
information about ASP.NET Impersonation please see:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaspnetimpersonatio
n.asp

http://support.microsoft.com/default.aspx?scid=KB;en-us;306158&

Hope it helps.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer
Get Secure! ¨C www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Chris" <[email protected]>
| Sender: "Chris" <[email protected]>
| Subject: Can't access CDO.Message
| Date: Wed, 23 Jul 2003 15:56:53 -0700
| Lines: 9
| 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: AcNRbbWnG3R1mJXpTfegJ5FX5W6V5w==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:48922
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I have a windows form application that I am trying to send
| mail from. Currently I have an ASP.net web application
| running that uses the same System.web.mail.mailmessage
| class, and the same smptp server which works fine. When
| trying to do the exact same thing from a windows form I
| get an error saying that it could not access the
| CDO.Message object.
|
| Why would there be a difference? How do I fix?
|
 
I think you've got it backwards. Chris said he *could* send messages
from ASP.NET, but *not* from Windows Forms.

Sorry but I don't have any ideas.


Lion said:
Hello Chris,

I think it is related with security setting of ASPNET account. The ASPNET
account needs to have sufficient permission to access a component and any
other resource that it requires. Please try the steps below to grant the
ASPNET the property permission.

1. Start -> Control Panel -> Administrative Tools -> Component Services.
2. Look for the desired COM component and add the ASPNET'user to the roles.

Alternatively, you can launch the aspnet_wp.exe with an account which has
enough permission. Please try these steps:

1. Find machine.config (usually under <windows
directory>\Microsoft.NET\Framework\v1.0.3705\CONFIG) and edit the
<processmodel> section. Change the "userName" attribute value to "SYSTEM".

2. Edit the "web.config" file in the ASP .NET project. Add the following
line:
<identity impersonate="true" userName=<your user name> password=<your
password> />

The user name you provide here need to have the permission to call the CDO
component.

3. Restart the aspnet_wp.exe. You can also kill it in Task Manager. Then
aspnet_wp will start using SYSTEM account.

You also can impersonate ASPNET as a user having permission. For more
information about ASP.NET Impersonation please see:

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaspnetimpersonatio
n.asp

http://support.microsoft.com/default.aspx?scid=KB;en-us;306158&

Hope it helps.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer
Get Secure! ¨C www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Chris" <[email protected]>
| Sender: "Chris" <[email protected]>
| Subject: Can't access CDO.Message
| Date: Wed, 23 Jul 2003 15:56:53 -0700
| Lines: 9
| 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: AcNRbbWnG3R1mJXpTfegJ5FX5W6V5w==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:48922
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I have a windows form application that I am trying to send
| mail from. Currently I have an ASP.net web application
| running that uses the same System.web.mail.mailmessage
| class, and the same smptp server which works fine. When
| trying to do the exact same thing from a windows form I
| get an error saying that it could not access the
| CDO.Message object.
|
| Why would there be a difference? How do I fix?
 
ck388 said:
I have the exact same problem. Does anyone have any idea why I can't
send mail from my VB.NET windows application? I have no problem
sending mail in a ASP.NET web application. Must be permission
problems...but I granted Admin rights to all my accounts.

Error: Could not access 'CDO.Message' object.

Look at the entire exception stack. "Could not access 'CDO.Message' object"
is probably only the message in the top exception of the stack. There's
another message in the InnerException of the top exception and, there may be
many more.

Use the .ToString() method of the top exception to get a string that
combines the messages from all of the exceptions in the stack.
 
ck388 said:
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.SmtpMail.Send(MailMessage message)
at SendMail.MainForm.btnSend_Click(Object sender, EventArgs e) in
C:\My Documents\TELUS QWT Source
Code\SendMail\SendMail\MainForm.vb:line 289

Does this help?

You're two steps closer to solving the problem. Your VB app can't connect
to the SMTP server. Are you setting the SMTP Server? Is the server
rejecting your connection attempts? Can you telnet to port 25 of the SMTP
server?
 
ck388 said:
I've tried using the SMTP server through ASP.NET and it seems to work
whereas when I create a windows application, the email function DOES
NOT WORK on my computer...but when I moved it to another machine, it
works fine. So there is basically something wrong with my machine
settings.

Yes I can telnet to port 25 no problem. I see a message show up when I
telnet into the SMTP server successfully.

There doesn't seem to be a fix for my problem. I've searched
endlessly.....

Thanks for your replies. Any other suggestions?

Are you setting the SmtpMail.SmtpServer property in your VB code? If it's
not explicitly set in your code, SmtpMail.Send will try to figure out what
the local SMTP server is. I think it looks at registry keys that are set by
Outlook Express. That could explain why it works on one machine but not
another.
 
Yes. My code is:

Dim Message As New System.Web.Mail.MailMessage()
'Recipient's name and e-mail address
Message.To = "(e-mail address removed)"
'Your name and e-mail address
Message.From = "(e-mail address removed)"
Message.Body = "Test message text"
Message.Subject = "A Test"
'Your smtp server
System.Web.Mail.SmtpMail.SmtpServer = "abmsg001.corp.ads"
System.Web.Mail.SmtpMail.Send(Message)

Tim :-)
 
Fixed the problem. Here is my email to Microsoft (since I called
Microsoft to help me solve the problem) after I fixed the problem
myself.

-----SNIP-----
I can't pinpoint ONE thing I did to fix the problem.....but it could
be one of 3 things.
Actually I was surprised it worked this morning because last
night...even after some
changes...nothing worked. It just MAGICALLYstarted working this
morning. Weird.

1. I installed Office 2000 Service Pack 2...I forgot where I found
out or why I decided
to install this..I think it was from a post on google. Then for
some reason I checked the version
of Outlook after the install and found out the version number was
still the OLD version
number so the install didn't seem to take effect.

Because of this, I found on the Microsoft website that there were
seperate downloads for
Outlook fixes. I then installed these fixes, one being "Outlook
2000 SR-1 Update: E-mail
Security" and the other being "Outlook 2000 Collaboration Data
Objects (CDO) Update:
Security" (these required the Office 2000 installation cd).

Here is a snippet from the Microsoft website:

The Outlook 2000 Collaboration Data Objects (CDO) Security Update
provides a higher level of security against most viruses, such as the
ILOVEYOU and Melissa viruses, as well as other viruses that spread
themselves through e-mail. CDO is a technology designed to simplify
the creation of applications with messaging functionality, or to add
messaging functionality to existing applications. For example, CDO and
Active Server Pages provide script support to create, send, and
receive e-mail on a Web site.

Strange thing is that after I installed these the I tried sending
using CDO and it still
DID NOT work ie I would still get the email error message. So
that's why I don't know
if this reason was the reason it started working this morning.

2. I then did a test to use another mail server....in particular
mail.telus.net (which is the
mail server that I am "supposed" to use at home (I use my own
smtp server actually)).
Accidentally I typed in mail.telus.com instead of mail.telus.net
in the test.vbs (vbscript
CDO) file so I got an error, the same error as before (it would
not work becaused I was
using a wrong, invalid mail server). So then I ran my VB.NET
windows application EMAIL
program...and I commented out the line where I set the
SmtpServer. Before I did this I
changed the default SMTP delivery address (for my local SMTP
server) to mail.telus.net.
So this worked.......as expected because this was the WORKAROUND
that DAN " THE
MAN" suggested.

This morning I was thinking of trying these other two mail
servers.....in particular
BCMSG010 and BCMSG020 (020, i think) which are also two other
smtp mail
servers that TELUS uses (I got these from mailer.vb...which is
shared code that
one of us at TELUS wrote to automate sending out of emails). When
I went to edit
the test.vb file I discovered that I put in mail.telus.com
instead of mail.telus.net.
So I changed it to mail.telus.net and then when I ran test.vb it
MAGICALLY started
working and I was receiving emails (to my home account) without
getting the error
message. I then logged on to my company VPN....and changed the
smtp server
to abmsg001.......and IT WORKED also.

3. Could it also be the fact that the LOCAL profile...finally got
propogated to the
exchange server? When I logged in to Keith's machine yesterday my
profile
was still REMOTE on his machine. But on machine it was LOCAL.
Maybe it
takes some time for the propogation to happen?
-----SNIP-----

Regards,

Tim :-)
 
Back
Top