View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default If statement to send email

Use this

Dim StrTo As String
If Sheets("Sheet1").Range("A7").Value = "D" Then
StrTo = "
Else
StrTo = "
End If

and this in the to line
..To = StrTo


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael McClellan" wrote in message om...
Want to give this one a try?

Why does all email get sent to and never to


If (Range("A7").Value = "D") Then
.To = "
Else
.To = "
End If
.CC = ""
.BCC = ""
.Subject = "ORDER ENTERED: " & CurrDir
.Body = "Hi there. Your order: " & CurrDir & " has been
entered." & vbNewLine & _
"This is an automatically generated message. GET
MORE ORDERS!"
'.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With