Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Send e-mail from Excel macro problem

I'm receiving the following error:

Compile error: user-defined type not defined

It's not recognizing this:

Dim objOutlk As New Outlook.Application 'Outlook

I've compared it to others online, and it looks the same, but I must be
missing something?

The code is below. Any help would be much appreicated! Thanks!

Sub SendEmails()

Application.ScreenUpdating = False

Dim Row, Col As Integer
Dim ConfDate, UName, UNumber As String

Row = 2
ConfDate = Application.InputBox("Enter the date attestation should be
received: eg (Friday August 18, 2006")
UName = Application.InputBox("Enter your name as it will appear at the
bottom of the email")
UNumber = Application.InputBox("Enter your phone number as it will appear at
the bottom of the email")
Workbooks.Open Filename:="[server path]\Business Leaders.xls"

Range("A2").Activate
Do
If Cells(Row, 1).Value = "Investigate" Then
MsgBox ("One file found where investigation is required- Name
Investigate.xls")

Else
MsgBox "Click to Send Email"
Dim objOutlk As New Outlook.Application 'Outlook
Dim objMail As MailItem 'Email item
Dim strMsg
Const olMailItem = 0

'Create a new message
Set objOutlk = New Outlook.Application
Set objMail = objOutlk.CreateItem(olMailItem)
objMail.To = Cells(Row, 1).Text
objMail.cc = Cells(Row, 2).Text
objMail.Subject = "User Verification " & " - " & Cells(Row, 1).Text & " " &
Date$
'Add the body
strMsg = Null

strMsg = "Hello " & Cells(Row, 2).Text & vbCrLf & vbCrLf

[etc...]
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Send e-mail from Excel macro problem

You need to create a reference to the Outlook library. In the VBE select
Tools - References - Microsoft Outlook. Note that you are performing early
binding when you do this whcih means that you can not use this on other
systems that do not have the save version of Outlook. You would need late
binding to do that.

Also take a look at this link on declaring variables. Many of your variables
are declared improperly.

http://www.cpearson.com/excel/variables.htm
--
HTH...

Jim Thomlinson


"Nico" wrote:

I'm receiving the following error:

Compile error: user-defined type not defined

It's not recognizing this:

Dim objOutlk As New Outlook.Application 'Outlook

I've compared it to others online, and it looks the same, but I must be
missing something?

The code is below. Any help would be much appreicated! Thanks!

Sub SendEmails()

Application.ScreenUpdating = False

Dim Row, Col As Integer
Dim ConfDate, UName, UNumber As String

Row = 2
ConfDate = Application.InputBox("Enter the date attestation should be
received: eg (Friday August 18, 2006")
UName = Application.InputBox("Enter your name as it will appear at the
bottom of the email")
UNumber = Application.InputBox("Enter your phone number as it will appear at
the bottom of the email")
Workbooks.Open Filename:="[server path]\Business Leaders.xls"

Range("A2").Activate
Do
If Cells(Row, 1).Value = "Investigate" Then
MsgBox ("One file found where investigation is required- Name
Investigate.xls")

Else
MsgBox "Click to Send Email"
Dim objOutlk As New Outlook.Application 'Outlook
Dim objMail As MailItem 'Email item
Dim strMsg
Const olMailItem = 0

'Create a new message
Set objOutlk = New Outlook.Application
Set objMail = objOutlk.CreateItem(olMailItem)
objMail.To = Cells(Row, 1).Text
objMail.cc = Cells(Row, 2).Text
objMail.Subject = "User Verification " & " - " & Cells(Row, 1).Text & " " &
Date$
'Add the body
strMsg = Null

strMsg = "Hello " & Cells(Row, 2).Text & vbCrLf & vbCrLf

[etc...]

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Send e-mail from Excel macro problem

Thanks Jim, I knew it had to be something straightforward I was missing.

"Jim Thomlinson" wrote:

You need to create a reference to the Outlook library. In the VBE select
Tools - References - Microsoft Outlook. Note that you are performing early
binding when you do this whcih means that you can not use this on other
systems that do not have the save version of Outlook. You would need late
binding to do that.

Also take a look at this link on declaring variables. Many of your variables
are declared improperly.

http://www.cpearson.com/excel/variables.htm
--
HTH...

Jim Thomlinson


"Nico" wrote:

I'm receiving the following error:

Compile error: user-defined type not defined

It's not recognizing this:

Dim objOutlk As New Outlook.Application 'Outlook

I've compared it to others online, and it looks the same, but I must be
missing something?

The code is below. Any help would be much appreicated! Thanks!

Sub SendEmails()

Application.ScreenUpdating = False

Dim Row, Col As Integer
Dim ConfDate, UName, UNumber As String

Row = 2
ConfDate = Application.InputBox("Enter the date attestation should be
received: eg (Friday August 18, 2006")
UName = Application.InputBox("Enter your name as it will appear at the
bottom of the email")
UNumber = Application.InputBox("Enter your phone number as it will appear at
the bottom of the email")
Workbooks.Open Filename:="[server path]\Business Leaders.xls"

Range("A2").Activate
Do
If Cells(Row, 1).Value = "Investigate" Then
MsgBox ("One file found where investigation is required- Name
Investigate.xls")

Else
MsgBox "Click to Send Email"
Dim objOutlk As New Outlook.Application 'Outlook
Dim objMail As MailItem 'Email item
Dim strMsg
Const olMailItem = 0

'Create a new message
Set objOutlk = New Outlook.Application
Set objMail = objOutlk.CreateItem(olMailItem)
objMail.To = Cells(Row, 1).Text
objMail.cc = Cells(Row, 2).Text
objMail.Subject = "User Verification " & " - " & Cells(Row, 1).Text & " " &
Date$
'Add the body
strMsg = Null

strMsg = "Hello " & Cells(Row, 2).Text & vbCrLf & vbCrLf

[etc...]

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get my Excel macro to automatically send mail using Outl Argent Excel Programming 0 April 10th 08 02:20 PM
Send mail problem Ludo Excel Programming 4 October 7th 07 11:37 AM
How to send a mail from excel macro using Lotus notes... Raj Excel Programming 2 August 10th 06 09:26 PM
Macro to automatically open a website or send an e-mail in excel Byron Excel Discussion (Misc queries) 3 April 7th 06 09:05 AM
send mail with MAPI problem Ludo Soete Excel Programming 0 July 21st 04 08:18 PM


All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"