If statement to send email

M

Michael McClellan

Want to give this one a try?

Why does all email get sent to [email protected] and never to
[email protected]

If (Range("A7").Value = "D") Then
.To = "[email protected]"
Else
.To = "[email protected]"
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
 
C

Charles

Michale,

Try,

If (Range("A7").Value = "D") Then
.To = "[email protected]"
Else: <<<<< add
.To = "[email protected]"
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


HTH

Charle
 
N

Nigel

Change your logic to

If Range("A7").Value = "D" then

or to be more precise you might want to text for upper case and trim any
spaces from the cell

If Ucase(Trim(Range("A7").Value)) = "D" then

Cheers
Nigel
 
Top