View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vlad999[_25_] Vlad999[_25_] is offline
external usenet poster
 
Posts: 1
Default Send out email if


This is what I have come up with from chopping up code i find on forums

When I run the macro I get an error on "Dim objOL As New
Outlook.Application" so i dont even know if the Code is any good but i
doubt it :(




Code:
--------------------

Sub SendEmail()

Dim LSearchRow As Integer
Dim LCopyToRow As Integer
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)

On Error GoTo Err_Execute

LSearchRow = 1

LCopyToRow = 2

While Len(Range("F" & CStr(LSearchRow)).Value) 0


If Range("F" & CStr(LSearchRow)).Value = "RG Complete" Then

With objMail
.To = "
.Subject = "Automated Mail Response"
.Body = "This is an automated message from Excel. " & _
"The cost of the item that you inquired about is: " & _
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select & "."
.Display
End With
Set objMail = Nothing
Set objOL = Nothing
End Sub

--------------------


--
Vlad999
------------------------------------------------------------------------
Vlad999's Profile: http://www.excelforum.com/member.php...o&userid=33586
View this thread: http://www.excelforum.com/showthread...hreadid=553949