0 Agios
Well-known Member
- Joined
- Feb 22, 2004
- Messages
- 570
- Office Version
- 365
when i use the page from the vba 2500 examples the code works fine, then i copy to a module in my work book vba and i get an error "User - Defined type not defined"
Option Explicit
Sub SendMessage1()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("hans@herber.de")
.Subject = "This is from Outlook-Test"
.Body = ActiveSheet.Range("F20")
.Importance = olImportanceHigh
objOutlookRecip.Resolve
.Send
End With
Set objOutlook = Nothing
End Sub
Option Explicit
Sub SendMessage1()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("hans@herber.de")
.Subject = "This is from Outlook-Test"
.Body = ActiveSheet.Range("F20")
.Importance = olImportanceHigh
objOutlookRecip.Resolve
.Send
End With
Set objOutlook = Nothing
End Sub