Trying to use CDO

G

Guest

Hi All

If possible, can i get a bit of help with this? Been trying to use CDO and getting very confused
I've been looking at Dicks Clicks website (http://www.dicks-clicks.com/excel/olSending.htm#Sending_an_E-mail_with_Attachments)
and have put together the below macro. However, it gives me a "User-defined type not defined" error and highlights the line "Dim olApp As Outlook.Application
I'm wanting to use late binding, as this macro will be used from multiple machines
Can anyone suggest where i'm going wrong
Also, with using late binding, do i need to have Outlook open? or will i need to define a mail server and account for it to use

Cheers and thanks
A

Sub SendWithAtt(

Dim olApp As Outlook.Applicatio
Dim olMail As MailIte

Set olApp = New Outlook.Applicatio
Set olMail = olApp.CreateItem(olMailItem

With olMai
.To = "(e-mail address removed)
.Subject = "Failure Notification
.Body = "Failure of system process.
.Sen
End Wit

Set olMail = Nothin
Set olApp = Nothin

End Su
 
R

Rob Bovey

Hi All,

You're probably getting this error because you haven't referenced the
Outlook object library. You say you want to use late binding, which works
without referencing the object library. But in that case you can't declare
variables with specific Outlook object types. They all need to be declared
As Object. And without an object library reference, you can't use the = New
syntax to create a new instance of Outlook or refer to Outlook constants by
name (olMailItem). You have to use CreateObject and numeric equivalents
instead. A partial modification of the code below shows what I mean.

Dim olApp As Object
Dim olMail As Object

Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


AL said:
Hi All.

If possible, can i get a bit of help with this? Been trying to use CDO and getting very confused.
I've been looking at Dicks Clicks website (http://www.dicks-clicks.com/excel/olSending.htm#Sending_an_E-mail_with_Atta
chments)
and have put together the below macro. However, it gives me a
"User-defined type not defined" error and highlights the line "Dim olApp As
Outlook.Application"
I'm wanting to use late binding, as this macro will be used from multiple machines.
Can anyone suggest where i'm going wrong?
Also, with using late binding, do i need to have Outlook open? or will i
need to define a mail server and account for it to use?
 
T

Tom Ogilvy

If you are really trying to use CDO vice automating outlook, chech out Ron
de Bruin's page

http://www.rondebruin.nl/

I don't believe Dick addresses CDO on his page.

--
Regards,
Tom Ogilvy


AL said:
Hi All.

If possible, can i get a bit of help with this? Been trying to use CDO and getting very confused.
I've been looking at Dicks Clicks website (http://www.dicks-clicks.com/excel/olSending.htm#Sending_an_E-mail_with_Atta
chments)
and have put together the below macro. However, it gives me a
"User-defined type not defined" error and highlights the line "Dim olApp As
Outlook.Application"
I'm wanting to use late binding, as this macro will be used from multiple machines.
Can anyone suggest where i'm going wrong?
Also, with using late binding, do i need to have Outlook open? or will i
need to define a mail server and account for it to use?
 
D

Dick Kusleika

Al

Tom's right, I don't cover CDO on my page. If you want to use Outlook late
bound, make sure you read this page

http://www.dicks-clicks.com/excel/olBinding.htm

It will explain what you need to do to convert it to late bound.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

AL said:
Hi All.

If possible, can i get a bit of help with this? Been trying to use CDO and getting very confused.
I've been looking at Dicks Clicks website (http://www.dicks-clicks.com/excel/olSending.htm#Sending_an_E-mail_with_Atta
chments)
and have put together the below macro. However, it gives me a
"User-defined type not defined" error and highlights the line "Dim olApp As
Outlook.Application"
I'm wanting to use late binding, as this macro will be used from multiple machines.
Can anyone suggest where i'm going wrong?
Also, with using late binding, do i need to have Outlook open? or will i
need to define a mail server and account for it to use?
 

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