Error Msg while using Outlook Object Model in VB

M

Mach

Hello,

I am writing an Visual Basic 6.0 application which will
send e-mails to the user based on certain condition.

For this I am using Visual Basic 6.0 and reference to
Microsoft Outlook 9.0 Object library. I am using Outlook
2000.

Following is the Error which I get when Outlook client is
not running.


" Run-time error '-2010103803 (88304005)':

Cannot create the e-mail message because a location to
send and receive message could not be found. To add a
location, click the tools menu, click services, and then
click the Delivery tab."

But everything works fine when Outlook client is running.

Any help will be highly appreciated.

Thanks.

Just in Case:
Code which I am executing is as follows:

-------------------------------
Dim objolapp As Outlook.Application
Set objolapp = CreateObject("Outlook.Application")
'logon - doesn't hurt if you're already logged in &
running...
Dim objolns As Outlook.NameSpace
Set objolns = objolapp.GetNamespace("MAPI")
objolns.Logon

Dim objolmail As Outlook.MailItem

Set objolmail = objolapp.CreateItem(olMailItem)
' this is the place, I get the error

'fill out & send message
objolmail.To = "(e-mail address removed)"
objolmail.Subject = "Hello World"
objolmail.Body = "place your HTML body here"
objolmail.Send

'logoff & clean up
objolns.Logoff
Set objolns = Nothing
Set objolmail = Nothing
Set objolapp = Nothing
 

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

Top