Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Trigger Email with Excel File Closed

Is it possible to trigger an Outlook email based on a date (example, today's
date) stored in a cell in an excel file that is closed?
For instance, the code below triggers the email if the file is open. would
it be possible to make it work every day and keep the file closed? Thanks and
thanks to Ron for the code below.

Sub TestFile()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In
Sheets("Sheet1").Columns("B").Cells.SpecialCells(x lCellTypeConstants)
If cell.Value Like "*@*" And LCase(cell.Offset(0, 4).Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
..To = cell.Value
..Subject = cell.Offset(0, 1).Value
..Body = cell.Offset(0, 2).Value
..Send 'Or use Display
End With
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Trigger Email with Excel File Closed

Filo

NO
--
DownThePaint
Where points are scored and games are won!


"Filo" wrote:

Is it possible to trigger an Outlook email based on a date (example, today's
date) stored in a cell in an excel file that is closed?
For instance, the code below triggers the email if the file is open. would
it be possible to make it work every day and keep the file closed? Thanks and
thanks to Ron for the code below.

Sub TestFile()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In
Sheets("Sheet1").Columns("B").Cells.SpecialCells(x lCellTypeConstants)
If cell.Value Like "*@*" And LCase(cell.Offset(0, 4).Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cell.Value
.Subject = cell.Offset(0, 1).Value
.Body = cell.Offset(0, 2).Value
.Send 'Or use Display
End With
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Trigger Email with Excel File Closed

You could retrieve values from a closed workbook using a routine from John
Walkenbach:
http://j-walk.com/ss/excel/eee/eee009.txt
Look for either: GetDataFromClosedFile or GetValue.

And I don't know a way to return whether the value is the result of a formula or
a constant.

But since you're looping through column B, I would think opening that workbook
and processing all the cells would be much more efficient.


Filo wrote:

Is it possible to trigger an Outlook email based on a date (example, today's
date) stored in a cell in an excel file that is closed?
For instance, the code below triggers the email if the file is open. would
it be possible to make it work every day and keep the file closed? Thanks and
thanks to Ron for the code below.

Sub TestFile()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In
Sheets("Sheet1").Columns("B").Cells.SpecialCells(x lCellTypeConstants)
If cell.Value Like "*@*" And LCase(cell.Offset(0, 4).Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = cell.Value
.Subject = cell.Offset(0, 1).Value
.Body = cell.Offset(0, 2).Value
.Send 'Or use Display
End With
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub


--

Dave Peterson
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
Email trigger Ash D Excel Discussion (Misc queries) 2 November 8th 07 08:39 PM
Can you set a "trigger" in excel to send an email? Debbi Excel Worksheet Functions 1 January 20th 06 03:25 PM
Auto notify a list of people via email when excel file is closed Melanie Excel Programming 1 January 11th 06 03:01 PM
Can reciept of an email in outlook express be used to trigger an even in excell Jeff Excel Programming 0 September 15th 04 12:04 AM
Using a checkbox to trigger an email Chris Excel Programming 1 August 12th 03 11:00 PM


All times are GMT +1. The time now is 09:44 AM.

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"