ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Email Workbook (https://www.excelbanter.com/excel-programming/283610-email-workbook.html)

Merkling, Steven

Email Workbook
 
You don't have a reference to Outlook

In the VBA IDE goto TOOLS ---- References and make sure Outlook is selected

HTH
-Merk


11/25/03 04:30PM

I'm trying to get code that will email the active workbook
to an email address that is located in a cell A1. I found
the code below, but I get the following message whenever I
try to use it: "Compile Error: User-defined type not
defined". Any suggestions? Thanks! Matt

Sub Send_Msg()
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
With objMail
.To = Range ("A1")
.Subject = "Test"
.Body = "Test"
.Display
End With
Set objMail = Nothing
Set objOL = Nothing
End Sub



Matt[_20_]

Email Workbook
 
I'm trying to get code that will email the active workbook
to an email address that is located in a cell A1. I found
the code below, but I get the following message whenever I
try to use it: "Compile Error: User-defined type not
defined". Any suggestions? Thanks! Matt

Sub Send_Msg()
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
With objMail
.To = Range ("A1")
.Subject = "Test"
.Body = "Test"
.Display
End With
Set objMail = Nothing
Set objOL = Nothing
End Sub

No Name

Email Workbook
 
U need to make sure you have referenced the Microsoft
Outlook library.
Goto ToolsReferences.
Then select Microsoft Outlook (9.0/10) Object Library.

That should get your code working.
Cheers.
Russ.

-----Original Message-----
I'm trying to get code that will email the active

workbook
to an email address that is located in a cell A1. I

found
the code below, but I get the following message whenever

I
try to use it: "Compile Error: User-defined type not
defined". Any suggestions? Thanks! Matt

Sub Send_Msg()
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
With objMail
.To = Range ("A1")
.Subject = "Test"
.Body = "Test"
.Display
End With
Set objMail = Nothing
Set objOL = Nothing
End Sub
.



All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com