View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
thomas donino thomas donino is offline
external usenet poster
 
Posts: 89
Default opening outlook and populating

I have the following code which is started with a userform button.
It puts together the recipient string of email addresses, generates a random
subject line and message body, if the auto message is checked.
i now need to open out look, populate the sendto, subject and message body
with these things. Do i do this all in the same code? Should I build an email
function?
Any help would be appreciated.
My current code is below and is the code fro the userform button



Private Sub SendEmailBtn_Click()

Dim CBCtrl As MSForms.Control
Dim strReceipients As String
Dim MsgBody As String
'get the email addresses from the check boxes
For Each CBCtrl In RndmemailFrm.Controls
'If TypeOf CBCtrl Is MSForms.CheckBox Then
If TypeName(CBCtrl) = "CheckBox" Then
If CBCtrl.Object.Value = True Then
If InStr(CBCtrl.Caption, "@") 0 Then
strReceipients = strReceipients & ";" & CBCtrl.Caption
End If
End If
End If
strReceipients = Mid(strReceipients, 1)
Next
' generate the random subject line from the table in column 2
SubLine = Cells(Rnd * (Cells(Rows.Count, 2).End(xlUp).Row - 1) + 2, 2)
' if the Use Automated message is checked, then randomly select a message
from column 3
' or else use the message in the message text box
For Each CBCtrl In RndmemailFrm.Controls
If CBCtrl.Tag = "AutoMess" Then
If CBCtrl.Object.Value = True Then
MsgBody = Cells(Rnd * (Cells(Rows.Count, 3).End(xlUp).Row - 1) + 2, 3)
Else
MsgBody = RndmemailFrm.MsgBdyTB.Text
End If
End If
Next
End Sub