Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If statement to send email

Michale,

Try,

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


HTH

Charle

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default If statement to send email

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

"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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i send an automated email from excel using an if statement Daniel Excel Worksheet Functions 0 August 5th 08 11:07 AM
send email to each customer email in excel sheet. -keevill- Excel Discussion (Misc queries) 3 July 17th 08 02:33 PM
send wkbk as an email attachment with an email address copied from SueInAtl Excel Discussion (Misc queries) 0 May 21st 07 10:53 PM
body of email disappears when I send an email from Excel ~A Excel Discussion (Misc queries) 0 February 25th 05 10:55 PM
send email gall Excel Discussion (Misc queries) 1 February 23rd 05 10:43 PM


All times are GMT +1. The time now is 07:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"