Send email using CDO Objects and Exchange Server
Posted on 2005-05-06
I am trying to send email using CDO objects and Exchange server through VB. The code I am using is like this:
Private Sub Form_Load()
'References added: Microsoft ADO 2.7 Library and Micrsoft CDO for Exchange 2000 Library
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields
Set Flds = iConf.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingExchange
.Item(cdoSMTPServer) = "<exchange server ip address>"
.Item(cdoSendUserName) = "<my username>"
.Item(cdoSendPassword) = "<my password>"
.Item(cdoSendEmailAddress) = "<my email address>"
.Item(cdoURLProxyServer) = "<proxy server address:port>"'Proxy server is necessary as my machine is in another domain which is different than the exchange server domain.
.Item(cdoURLProxyBypass) = "<local>"
.Item(cdoURLGetLatestVersion) = True
Set iMsg.Configuration = iConf
Set Flds = iMsg.Fields
.Item(cdoTo) = "<my email address>"
.Item(cdoFrom) = "<my email address>"
.Item(cdoSender) = "<my email address>"
.Item(cdoSubject) = "Check this stuff out."
.HTMLBody = "Body"
I am getting error "Could not find the Sender's mailbox." at iMsg.Send method call.
Then referring some documentation online, I added this line
.Item(cdo.cdoMailboxURL) = "file://./backofficestorage/<my exchange server domain name>/MBX/<my alias>"
Now I am getting error "Object or data matching the name, range, or selection criteria was not found within the scope of this operation." at same method call
Do you have any idea how to resolve this issue?
Eventually I have to implement this code on a web page using ASP. Let me also know if there would be any problems in that.
Thanks for your time,