CDO.Message.DataSource.Open() in .NET

  • Thread starter Thread starter Zoury
  • Start date Start date
Z

Zoury

Hi folks! :O)

I need to take a email from a given mailbox and forward it to another
mailbox.

The code we had in VB 6 looked like this one :
'***
Dim objMsg As Object
Dim objFwd As Object

' get the mail we need to forward
Set objMsg = CreateObject("CDO.Message")
objMsg.DataSource.Open strMsgAddr, , 3, , , strUsername, strPassword

' create the forward mail, update the addresses
' and sends the mail
Set objFwd = objMsg.Forward
objFwd.To = strToAddr
objFwd.From = strFromAddr
objFwd.send
'***

since i need to convert this code into VB.NET code, I was wondering if CDO
was still the way to go ?

also, how would .NET (via CreateObject()) handles late-binding ? does it
create an interop-wrapper assembly at runtime ? is it slower than it was
before the "managed Era"...


and finally I's like to wish a Happy New Year to all you !! :OD
 
The SMTPMail class in the 1.1 framework is just a wrapper over CDO. There
is no reason not to simply continue to use CDO directly, especially since
your code does things that the wrapper doesn't let you get to. It won't be
any slower in the managed space. I don't see any reason to do late binding,
though. You can reference the CDO objects at design time and .Net will
create the CCW on the spot for you.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Hi,

Take a look at the mailmessage class.
http://msdn.microsoft.com/library/d...l/frlrfsystemwebmailmailmessageclasstopic.asp

Ken
-----------------
"Zoury" <yanick_lefebvre at hotmail dot com> wrote in message
Hi folks! :O)

I need to take a email from a given mailbox and forward it to another
mailbox.

The code we had in VB 6 looked like this one :
'***
Dim objMsg As Object
Dim objFwd As Object

' get the mail we need to forward
Set objMsg = CreateObject("CDO.Message")
objMsg.DataSource.Open strMsgAddr, , 3, , , strUsername, strPassword

' create the forward mail, update the addresses
' and sends the mail
Set objFwd = objMsg.Forward
objFwd.To = strToAddr
objFwd.From = strFromAddr
objFwd.send
'***

since i need to convert this code into VB.NET code, I was wondering if CDO
was still the way to go ?

also, how would .NET (via CreateObject()) handles late-binding ? does it
create an interop-wrapper assembly at runtime ? is it slower than it was
before the "managed Era"...


and finally I's like to wish a Happy New Year to all you !! :OD
 
Hi Nick!
The SMTPMail class in the 1.1 framework is just a wrapper over CDO.

Yeah I know. I've got 2 different CDO Libraries here CDO 1.21 and CDOEX...
do you happen to know which one was wrapped ? is CDO 1.21 library an
obsolete version ?

I don't see any reason to do late binding,
though. You can reference the CDO objects at design time and .Net will
create the CCW on the spot for you.

i guess they used late-binding to support further versions of CDO or to
avoid DLL hell somehow... ;O)


Thanks for your input!
 
Hi Ken! :O)

is there something i've missed from this page ? i've looked at it a lot you
know.. ;O)
 

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

Back
Top