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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Send out email if

Hi Vlad999,

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 :(


Without otherwise looking at your code, you need to set a reference:

Tools | References | select 'Microsoft Outlook xx Object Library'

where xx is a version number.


Additionally, I would suggest that you change:

Dim objOL As New Outlook.Application


to

Dim objOL As Outlook.Application

In this connection, see Chip Pearsons explanation at:

http://www.cpearson.com/excel/variables.htm

See particularly the section entitled: 'Don't Use The New Keyword In A Dim
Statement'


---
Regards,
Norman


"Vlad999" wrote in
message ...

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



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
send email to each customer email in excel sheet. -keevill- Excel Discussion (Misc queries) 3 July 17th 08 02:33 PM
Send Email kirrages Excel Discussion (Misc queries) 3 May 23rd 07 06:00 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
send email with email addresses in a range of cells Craig[_24_] Excel Programming 1 October 10th 05 09:26 PM
body of email disappears when I send an email from Excel ~A Excel Discussion (Misc queries) 0 February 25th 05 10:55 PM


All times are GMT +1. The time now is 01:59 AM.

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

About Us

"It's about Microsoft Excel"