outlook automation

C

Curt

The following code gets the e-mail addresses and send e-mails ok. What I
havent been able to do is stop display. Would like to send as now without
having display then close each one. Would someone see if you can kick me
where I have left something out.
Thanks

'Send E-Mails
Private Sub OptionButton9_Click()
OptionButton9.Value = False
UserForm4_Letters.Hide
Sheets("E-mail test").Select
'Dim objOutlook As Outlook.Application
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Bonus As String
Dim Msg As String
' Sheets("E-mail test").Select
'Create Outlook object
Set OutlookApp = CreateObject("Outlook.Application")
'Loop through the rows
For Each cell In Columns("K").Cells.specialcells(xlcelltypeconstants)
If cell.Value Like "*@*" Then
'Get the data
Subj = "Veteran's Day Parade"
Recipient = cell.Offset(0, -1).Value
EmailAddr = cell.Value
'Compose message
Msg = "Dear Participant:" & vbCrLf & vbCrLf
Msg = Msg & "I am pleased to inform you that" & vbCrLf & vbCrLf
Msg = Msg & "Your CD of Veteran's Day Parade Is available "
Msg = Msg & Bonus & vbCrLf & vbCrLf
Msg = Msg & "Dan Rupe" & vbCrLf
Msg = Msg & "Chairman"
Msg = Msg & "sent by program" & vbCrLf
'Create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = EmailAddr
.subject = Subj
.Body = Msg
'.Display
.Send
' .Close
End With
End If
'Set OutlookMsg = Nothing
Set OutlookApp = Nothing
' Set mOutlookApp = Nothing
Next
End Sub
 
G

Gordon Bentley-Mix

Curt,

Little clues like
For Each cell In Columns("K").Cells.specialcells(xlcelltypeconstants)
tell my you're probably working with Excel. This is the Word VBA forum. Try
your question a few doors down. ;-D
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top