Okay so I have a user form and when I click okay and I want it to send an email to the people whos chkboxes = true and I want it to contain a message body that is dependent on water quality varibles chkboxes = true
not included in this code is the cmdOk_Click() which will call the email function. Here is the userform code.
here is the code for the sendmail function
Again I don't know how to make the strbody take if statements or what but I also don't know how to change the .to line to be varible. Any help would be greatly greatly appreciated.
Greg
not included in this code is the cmdOk_Click() which will call the email function. Here is the userform code.
Code:
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Select Case frmOtter.txtPh
Case 0 To 8#
chkPh = True
Case 8.5 To 100
chkPh = True
Case Else
chkPh = False
End Select
Select Case frmOtter.txtNh3
Case 0.1 To 100
chkNh3 = True
Case Else
chkNh3 = False
End Select
Select Case frmOtter.txtSal
Case 0 To 27
chkSal = True
Case 36 To 1000
chkSal = True
Case Else
chkSal = False
End Select
Select Case frmOtter.txtNo3
Case 35 To 10000
chkNo3 = True
Case Else
chkNo3 = False
End Select
If frmOtter.txtNo3.Value = "over" Then
chkNo3 = True
Else
If frmOtter.txtNo3.Value = "35+" Then
chkNo3 = True
Else
chkNo3 = False
End If
End If
Select Case frmOtter.txtWtemp
Case 0 To 47
chkWtemp = True
Case 60 To 510
chkWtemp = True
Case Else
chkWtemp = False
End Select
Select Case frmOtter.txtCl
Case 0.1 To 100
chkCl = True
Case Else
chkCl = False
End Select
Select Case frmOtter.txtAlk
Case 0 To 150
chkAlk = True
Case 250 To 1000
chkAlk = True
Case Else
chkAlk = False
End Select
chkAtemp = False
chkNo2 = False
chkColi = False
chkOrp = False
chkbjohnsons = False
chkClobue = False
chkDbrandt = False
chkEhuber = False
chkEporter = False
chkGanderson = False
chkJrarnold = False
chkJohnHewitt = False
chkKgrzenda = False
chkLripley = False
chkLewinger = False
chkMkelley = True
chkNhardy = False
chkPbeaven = False
chkRtoth = False
chkSalbes = False
chkTdyer = False
End Sub
here is the code for the sendmail function
Code:
Sub Mail_small_Text_Outlook()
' Is working in Office 2000-2007
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
strbody = "Greg" & vbNewLine & vbNewLine & _
"This is an automated message to let you know that on" & vbNewLine & _
Format(Date, "Short Date") & vbNewLine & _
"Sea Otters pH is " & ActiveCell.Value & vbNewLine & _
"This is just a warning message so that the proper steps can be taken" & vbNewLine & _
"Please feel free to let life Support know if we can be of any assistance" & vbNewLine & vbNewLine & _
vbNewLine & _
"Thank You," & vbNewLine & _
"Life Support"
On Error Resume Next
With OutMail
.To = "lxdawg25@gmail.com"
.CC = ""
.BCC = ""
.Subject = "A Message from your friendly Life Support Staff"
.Body = strbody
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Again I don't know how to make the strbody take if statements or what but I also don't know how to change the .to line to be varible. Any help would be greatly greatly appreciated.
Greg