LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Excel / VBA to automatically email forms - how?

Tom -

Thanks for the link.. I actually have read that page many many times.
Forgive me - but this is my first time working with events.. an
actually, the first time using VBA.

So far, the code I have come up with will run the macro when making
change to the worksheet. I would like this to run the macro only upo
closure of the workbook. Any suggestions on what I should change? B
the way, all of this code is placed in "Sheet1".

Thanks for *any* help anyone can and / or has provided!
Andrew


Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Application.EnableEvents = False
Call CDO_Send
Application.EnableEvents = True
End Sub


Sub CDO_Send()

Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Dim WB As Workbook
Dim WBname As String
Dim cell As Range

Application.ScreenUpdating = False

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "163.186.80.4"
.Item(cdoSMTPServerPort) = 25
.Update
End With
For Each cell I
Sheets("Sheet1").Columns("J").Cells.SpecialCells(x lCellTypeConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Value Like "*@*" And cell.Offset(0, 1).Value
"yes" Then
With iMsg
Set .Configuration = iConf
.To = cell.Value
.From = """Inventario de Almacen"" <"
.Subject = "Comprar Partes"
.TextBody = "Dear " & cell.Offset(0, -1).Value & vbNewLine
vbNewLine & _
"Part number needs to be ordered."
.Send
End With
End If
End If
Next cell

Set iMsg = Nothing
Set iConf = Nothing
Set WB = Nothing
Application.ScreenUpdating = True
End Su

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

 
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
Need to automatically number order forms in excel upon opening? Mike1 Excel Discussion (Misc queries) 2 May 16th 06 07:59 PM
Email, forms, Excel, Infopath, Sharepoint Bettergains Excel Discussion (Misc queries) 0 November 10th 05 10:24 PM
Excel 97 generating email automatically starts Lotus 6. DefaultOK Simon Starter Excel Discussion (Misc queries) 1 August 25th 05 08:43 PM
How do I automatically send daily email of updated Excel workbook. How to automate emails with excel file. Excel Discussion (Misc queries) 1 May 9th 05 08:55 PM
Excel Forms - text fields decompressing font automatically EM Excel Discussion (Misc queries) 0 March 11th 05 03:37 PM


All times are GMT +1. The time now is 06:27 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"