T.I.A.
Code: Select all
Option Explicit
Sub SendMessage()
Dim objApp As Object
Dim objMsg As Object
Dim objRec As Object
Dim objAtt As Object
On Error Resume Next
Set objApp = GetObject(, "Outlook.Application")
If objApp Is Nothing Then
Set objApp = CreateObject("Outlook.Application")
If objApp Is Nothing Then
MsgBox "Failed to start Outlook.", vbCritical
Exit Sub
End If
End If
On Error GoTo ErrHandler
Set objMsg = objApp.CreateItem(0) ' olMailItem
objMsg.Subject = "Water Meter Reading"
objMsg.Body = Range("N25") & " " & Range("O25") _
& vbCrLf & Range("N29") & " " _
& Format(Range("O29").Value, "#.00")
Set objRec = objMsg.Recipients.Add("myaddress.ca")
objRec.Resolve
' Set objAtt = objMsg.Attachments.Add("C:\Files\Test.zip")
' Send
' objMsg.Send
' or show
objMsg.Display
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub