If statement to send email

  • Thread starter Thread starter Michael McClellan
  • Start date Start date
M

Michael McClellan

Want to give this one a try?

Why does all email get sent to (e-mail address removed) and never to
(e-mail address removed)

If (Range("A7").Value = "D") Then
.To = "(e-mail address removed)"
Else
.To = "(e-mail address removed)"
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
 
Use this

Dim StrTo As String
If Sheets("Sheet1").Range("A7").Value = "D" Then
StrTo = "(e-mail address removed)"
Else
StrTo = "(e-mail address removed)"
End If

and this in the to line
..To = StrTo
 
Michale,

Try,

If (Range("A7").Value = "D") Then
.To = "(e-mail address removed)"
Else: <<<<< add
.To = "(e-mail address removed)"
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
 
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
 

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

Back
Top