473,320 Members | 1,722 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,320 software developers and data experts.

COM Interop Problem - [CDO - [MAPI_E_UNCONFIGURED(8004011C)]]

Hello,

I'm having problems sending MAPI Mail from an ASP.NET applcation (in VB)
(which worked fine in traditional asp)

When run on our test server, it returns an COMException (0x80010106):
[Collaboration Data Objects - [UNKNOWN_ERROR(80010106)]]] exception from
MAPI.
(from the global.asa when trying to create MAPI session I get a .net
exception "Cannot change thread mode after it is set")

According to a post on the microsoft.public.in.csharp

"The 80010106 error usually occurs due to incompatible
threading models. ASP.NET uses an MTA thread pool
to service requests for the web service and looks like
the CDO component is apartment threaded (lives in an STA).

In traditional ASPX pages, you'd use the ASPCOMPAT
attribute set to true in the <%@ Page %> directive of an
ASPX page to make a ASP.NET use an STA thread
(instead of an MTA thread) to access the apartment threaded
COM component."

So I set the ASPCOMPAT attribute of the aspx page that calls this method to
"true".

This now appears to create the object correctly.

But returns a new error.
[Collaboration Data Objects - [MAPI_E_UNCONFIGURED(8004011C)]]

I think this may be due to the identity of the STA MAPI Component, being
different from the impersonated ASP.NET user in the Web.config file, but i'm
not sure.
Does anyone know....


a) How I can confirm this is the case?
b) Ensure that the MAPI component is running under the same identity?

I have included below the original legacy code from the traditional asp
application and the new COM Interop code from the ASP.NET version of my
application.

Any suggestions are welcome! particularly code examples ;-)

thank you very much.

Chris V.
'--------------------------------original mail.inc used in asp page
(works).----------------------------------------
Dim oSession
Set oSession = CreateObject("MAPI.Session")

oSession.Logon "", "", False, True, 0, True,
Application("ExchangeServerLocation") & vblf &
Application("ExchangeServerMailbox")

Dim oOutbox
Set oOutbox = oSession.Outbox

Dim oMessage
Set oMessage = oOutbox.Messages.Add
oMessage.Subject = Subject
oMessage.Text = Body

Dim oRecipient

For i = 0 To oVec.Count - 1
Set oRecipient = oMessage.Recipients.Add
oRecipient.Name = oVec(i)
oRecipient.Resolve
Set oRecipient = Nothing

Next

oMessage.Send

oSession.Logoff

Set oMessage = Nothing
Set oOutbox = Nothing
Set oSession = Nothing

'-----------------MAPIMESSAGE.VB (called from test.aspx with aspcompat set
to true.)-----------------------

Imports Microsoft.Office.Interop
Imports MAPI

Public Class MAPIMail
Implements IQPWMessageSender

Private mExchangeServer As String
Private mMailbox As String

Public Sub New(ByVal MAPIExchangeServer As String, ByVal MAPIMailbox As
String)
mExchangeServer = MAPIExchangeServer
mMailbox = MAPIMailbox
End Sub

Public Function SendMail(ByVal CommaDelimitedRecipients As String, _
ByVal Subject As String, ByVal Body As String) As Boolean Implements
IQPWMessageSender.SendMail

Dim recipients As String()

Dim oSession As New MAPI.Session
oSession.Logon("", "", False, True, 0, True, mExchangeServer & vbLf
& mMailbox)

Dim oOutbox As Object
oOutbox = oSession.Outbox

Dim oMessage As MAPI.Message

oMessage = oOutbox.Messages.Add
oMessage.Subject = Subject
oMessage.Text = Body

Dim oRecipient As Object

recipients =
QPWDataHelper.CSVToStringArray(CommaDelimitedRecip ients)
recipients = QPWMessage.RemoveDups(recipients)

Dim recip As String
For Each recip In recipients
If Trim(recip) <> "" Then
oRecipient = oMessage.Recipients.Add
oRecipient.Name = Trim(recip.ToString)
oRecipient.Resolve()
oRecipient = Nothing
End If
Next

If recipients.Length > 0 Then
Try
oMessage.Send()
Catch ex As Exception
QPWLog.WriteToLog("Mapi error" & ex.Message)
End Try
Else
QPWLog.WriteToLog("Did not send MAPI message as there were no
recipients.")
End If

oSession.Logoff()

oMessage = Nothing
oOutbox = Nothing
oSession = Nothing

End Function

End Class
'--------------------------------------
Nov 18 '05 #1
0 2206

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kurt | last post by:
Hi I am using CDO 1.21 from C# in order to iterate through the entries in a users outlook address book (as OOM was too slow). Basically I take the Name field from each "message" and insert it into...
8
by: Rob Edwards | last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message: "A reference to 'Microsoft CDO for Exchange Management Library' could not be...
1
by: W1ld0ne [MCSD] | last post by:
Using CDO from inside a .Net application works fine until you try to give it a strong name, then it wants to give your interop.CDO object a strong name as well and that can not be done (I think)....
4
by: Vittorio Pavesi | last post by:
Hello, I'm using CDO in my VB Application. Does anybody know how to set the Mail priority (Urgent, Medium, Low) ?? Thanks Vittorio...
8
by: Li Pang | last post by:
Hi, I used following codes to pass a message item from CDO to Outlook. They worked fine when I used outlook 2000, but get an error of "Specified cast is not valid." when I used Outlook 2003....
8
by: Philip Wagenaar | last post by:
I need Interop.MAPI.dll for a project, but where can I find this file?
11
by: Steve Smith | last post by:
I have written a winforms application that launches approximately 150 threads with Thread.ThreadStart() Each thread uses CDO 1.21 to logon to a different Exchange mailbox and send/receive a...
5
by: muriwai | last post by:
Hi, I have a C# assembly project under Visual Stuio 2008 Pro on Windows Server 2008. I converted the project from VS 2005. The project references COM->Microsoft CDO for Windows 2000 Library...
4
by: Christiano Donke | last post by:
i'm writing an app that uses an excel interop to convert the xls file to html.. while writing it, i had no problem... it problem is coming out when i try do deploy it... i've tried merging it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.