Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If statement to send email
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i send an automated email from excel using an if statement | Excel Worksheet Functions | |||
send email to each customer email in excel sheet. | Excel Discussion (Misc queries) | |||
send wkbk as an email attachment with an email address copied from | Excel Discussion (Misc queries) | |||
body of email disappears when I send an email from Excel | Excel Discussion (Misc queries) | |||
send email | Excel Discussion (Misc queries) |