View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
arjen van der wal arjen van der wal is offline
external usenet poster
 
Posts: 24
Default opening outlook and populating

There are a number of ways of doing this. Here's a copy of a relatively
simple routine that I use on a daily basis:

Sub MailIt()

Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")
Dim olNameSpace As Object
Set olNameSpace = olApp.GetNameSpace("MAPI")
Dim olFolder As Object
Set olFolder = olNameSpace.GetDefaultFolder(6)
Dim olMail As Object
Set olMail = olApp.CreateItem(0)

Dim sFileName As String
sFileName = "C:\VB 2008\sales.csv"

Dim sRecipient As String
sRecipient = "


With olMail
.Subject = "the subject"
.Recipients.Add sRecipient
.Body = "body message"
.Attachments.Add sFileName
.Display
.Send
End With

End Sub

It seems you already have your own message body and recipient list, so
just incorporate them into the code.
The above code could either go into a separate sub procedure with the
recipient & message from your procedure as inputs, or put it at the end of
your existing procedure (probably simpler).
There are quite few example procedures also available at:
http://www.rondebruin.nl/sendmail.htm

Hopefully this helps.