Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling outlook from excel

Status
Not open for further replies.

becshu

Technical User
Jan 28, 2003
18
US
I am trying to send email from Excel. The code I have will insert the subject and body from an excel sheet and send the email, but won't insert the recipient, so it just gets sent to me. This is what I have:

Sub SendEMail()

Dim objOL As Object
Dim objOLMsg As Object
Dim objOLRecip As Object

Set objOL = CreateObject("Outlook.Application")

For i = 1 To 3
Set objOLMsg = objOL.CreateItem(olMailItem)
With objOLMsg
Set objOLRecip = .Recipients.Add(Sheets(1).Cells(i, 3))
objOLRecip.Type = olto
.Subject = Sheets(1).Cells(i, 1)
.Body = Sheets(1).Cells(i, 2)
.Send
End With
Next i
Set objOL = Nothing
End Sub
 
Oops. I didn't have the outlook reference library installed. Solved my own problem.

But now another question, how do I set outlook so it doesn't have a pop-up stating that an outside control is trying to send email and asking for permission with each email?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top