Thread: Email
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Email

(I don't recall the full name)

1) Go to the VBA editor, Alt -F11
2) ToolsReferences in the Menu bar
3) Place a Checkmark before Microsoft Outlook ? Object Library
? is the Excel version number


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Dave Peterson" wrote in message ...
Maybe you need to add a reference to Outlook.

Inside the VBE with your project selected,
tools|references|search for MS Outlook (I don't recall the full name) and select
it.

If you'll share the workbook/macro with others and they run different versions
of Outlook, you may want to remove the reference and use late binding.

Dick Kusleika has a web page at:
http://www.dicks-clicks.com/excel/olBinding.htm
that explains this with Outlook



Alvin Hansen wrote:

Thank you very much
Its working but i get an error when i will assigned to a command button
i have this
Private Sub CommandButton1_Click()
Send_Msg()
End Sub
HEre i get an error
what do i do wrong
Regards alvin

"KRCowen" skrev:

Alvin

The following is code I use to automatically send an outlook message, with
values taken from a spreadsheet. The macro is assigned to a command button on
the worksheet.

Sub Send_Msg()

Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)

msg = "Dianne," & Chr(13) & Chr(13)
msg = msg & "The attached excel file shows a new job that needs to be setup." &
Chr(13)
msg = msg & "Please inform Bruce of the job number." & Chr(13) & Chr(13)
msg = msg & "Thanks. Ken"

addee = range("a1").value
CC = range("b1").value

With objMail
.To = addee
.CC = CC
.Subject = "New job"
.Body = msg
.Display
.Send
End With

Set objMail = Nothing
Set objOL = Nothing

MsgBox "File has been e-mailed to " & addee

End Sub

Like a lot of the stuff I use, this is patterned after something I learned in
this newsgroup.

I hope this helps.

Ken


--

Dave Peterson