See more discussions and posts about automation: Help Launch Automated Message After Product Build Simple automation - Assistant recherche Sripts for Natural Language Translation
1) Start Outlook 2) Select Tools > Macros > Macro (Alt-F8) 3) Enter a name for the new macro 4) Select Create then cut and paste the following code:
Option Explicit Dim KeepWaiting As Boolean
Public Sub Main()
Dim StartHour, Time2Pause, Start
Dim I As Integer
If (MsgBox("Press Yes to start macro", 4)) = vbYes Then
StartHour = Hour(Now)
KeepWaiting = True
I = 1
Do While KeepWaiting = True
If Hour(Now) >= StartHour + I Then
IsLogFileThere 'check every hour
I = I + 1
Else
Time2Pause = 30 ' Set pause duration.
Start = Timer ' Set start time.
Do While Timer < Start + Time2Pause
DoEvents ' Yield to other processes.
Loop
End If
Loop
'MsgBox "Debug Exit loop cause Keepwaiting = false"
Else
End
End If
End Sub
Sub IsLogFileThere()
On Error GoTo ERR_Trap
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem
Dim MSg As String
Dim FSO
Dim ws
Set ws = CreateObject("WScript.Network")
ws.MapNetworkDrive "X:", "\\rel52\c$"
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists("X:\GM\Logs\Release0.log") Then
'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")
'Create a new mail message item.
Set newMail = ol.CreateItem(olMailItem)
With newMail
'Add the subject of the mail message.
.Subject = "Testing automation Log and Report from GeoMedia builder"
'Create some body text.
MSg = "This is an automated message. " & Chr(10)
MSg = MSg & "Product Build Finished - Successful!" & Chr(10)
MSg = MSg & "Please read attached log file and correct any error." & Chr(10) & Chr(10)
MSg = MSg & "For more information and assistance, read the help file: " & Chr(10)
MSg = MSg & "http://theserver/thefolder/ISO_9000_CM_Help.chm" & Chr(10)
.Body = MSg
'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add("mylogin@contactez.net")
.Type = olTo
If Not .Resolve Then
MsgBox "Unable to resolve address.", vbInformation
Exit Sub
End If
End With
'Attach a file as a link with an icon.
With .Attachments.Add _
("X:\Folder1\Folder2\EndofBuild.log", olByReference)
.DisplayName = "Log Report from Huntsville Product Builder"
End With
'Send the mail message.
.Send
KeepWaiting = False
End With
'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
Else
'MsgBox "Debug - Log not found. Wait Until Found."
KeepWaiting = True
End If
ws.RemoveNetworkDrive "X:", True
ERR_Trap:
Select Case Err
Case 0:
Case Else:
MsgBox "Error in Outlook VBaProject Macro into Function IsLogFileThere " & Err
End
End Select
End Sub
For more information go to Google Groups Outlook Program VBA
| About me and my activities since 1995 - Developing solutions that really help - No gimmicks | ||
| Participation on Google Participation on Yahoo! Tek-Tips Forums dgschnei |
Listed since 1996 ixquick International Services Vivísimo platform sdk dgschnei |
Cooperation on Google About Me Gifts Home Decoration |