Help Launch Automated Message After Product Build

  • Thread starter Thread starter International Connections
  • Start date Start date
I

International Connections

How can I (safely) trigger an Outlook automated message depending on
the existence of a file located on another machine that does not have
Outlook installed.
I have two PCs on our network, one is my workstation and the other is
build machine for our products.

We are not allowed to install Outlook on the build machine because of
security risk caused by malicious emails and so on...

After the automated build of our products is completed a log is
created on the fly by the build automation.

When this log appears (meaning the build is done) I would like to
launch the Outlook Message on my machine to send an email message. I
created the macro and it works fine (see code below).

I wonder how I can check for the existence of this file using Outlook?
Is there an Outlook function that would check for existence of the log
file for Outlook VBscript?

What could be a good Outlook Script solution?
wait / loop / use a timer?
Is there an Outlook function to wait for the creation of a file before
starting an event?
Can Outlook check every hour using a timer of some sort?

Any help, example, or advice is very welcomed.

Thank you in advance.

Regards

PS: Please don't send me direct emails, use the newsroom or go to
http://contactez.net/portfolio.html

http://gurleyalabama.contactez.net

=========
Excerpt of my Outlook VB Script code:
(C:\Documents and Settings\MyLogin\Application Data\Microsoft\Outlook)
=========

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:", "\\BuilMachine\c$"

Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.fileExists("X:\Dominique\ProductBuild.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 = "Automation Log and Report from Product Builder"
'Create text for body
MSg = "This is an automated message. " & Chr(10)
MSg = MSg & "Product Build 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/Directory1/CM/GM_CM_Help.chm" &
Chr(10)
.Body = MSg

'Add a recipient to test to make sure that the address is
valid using Resolve method
With .Recipients.Add("(e-mail address removed)")
.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:\Dominique\ProductBuild.log", olByReference)
.DisplayName = "Log Report from Product Builder"
End With

'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing

Else

MsgBox "Log not found so Wait Until Found.....?????"

End If

ws.RemoveNetworkDrive "X:", True

End
 
You could use the shell command and access net send to
send a message to you letting you know the log is done.
It will pop up on your computer on top of whatever you're
doing until you press OK.
-----Original Message-----
How can I (safely) trigger an Outlook automated message depending on
the existence of a file located on another machine that does not have
Outlook installed.
I have two PCs on our network, one is my workstation and the other is
build machine for our products.

We are not allowed to install Outlook on the build machine because of
security risk caused by malicious emails and so on...

After the automated build of our products is completed a log is
created on the fly by the build automation.

When this log appears (meaning the build is done) I would like to
launch the Outlook Message on my machine to send an email message. I
created the macro and it works fine (see code below).

I wonder how I can check for the existence of this file using Outlook?
Is there an Outlook function that would check for existence of the log
file for Outlook VBscript?

What could be a good Outlook Script solution?
wait / loop / use a timer?
Is there an Outlook function to wait for the creation of a file before
starting an event?
Can Outlook check every hour using a timer of some sort?

Any help, example, or advice is very welcomed.

Thank you in advance.

Regards

PS: Please don't send me direct emails, use the newsroom or go to
http://contactez.net/portfolio.html

http://gurleyalabama.contactez.net

=========
Excerpt of my Outlook VB Script code:
(C:\Documents and Settings\MyLogin\Application Data\Microsoft\Outlook)
=========

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:", "\\BuilMachine\c$"

Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.fileExists("X:\Dominique\ProductBuild.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 = "Automation Log and Report from Product Builder"
'Create text for body
MSg = "This is an automated message. " & Chr(10)
MSg = MSg & "Product Build 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/Directory1/CM/GM_CM_Help.chm" &
 
Thank you for your help.
I appreciate that you took the time to answer me.

I would have preferred not to be present to keep the process going.
Often the build runs at night and we are not here to press the OK
button.

That is why I am trying to have Outlook kick the process after the log
is created, a little bit like a scheduled event... at regular
intervals maybe... The script I have checks for the log file, now I
have to find a way to run the script from outlook every hour or other
intervals...? If the log is present the mail is sent and the
execution of the script will be turned off.

I want to thank you again for your answer any help is always welcomed.

Regards

PS: Please don't send me direct emails, use the forum or go to
http://contactez.net/portfolio.html
http://gurleyalabama.contactez.net
 
I found a way to execute a timer and launch an automated message after
the build of our product(s) is done. Until now this VBA macro works
like a charm and the end-of-build message is sent programmatically.
The idea was to use a timer event to occur within my Outlook to call a
particular function. Every "XYZ" seconds my Outlook executes a part
of the VBA code to check for the existence of a log file on another PC
on our network, which does not have Outlook. To do so I use a timer in
conjunction with the Now function. If the log file is found, a message
is sent, and the macro stops.

Here is the code I came up with and because the genuine goal and
interest of forums is to share information, and share ideas I also
posted a copy after removing some information that do not need to be
public. Maybe somebody else can use such code. It can be modified, and
improved to fit other needs. I hope I can help others as others have
helped me. Thanks in advance if someone sees and shares good
modifications to improve this code.

Please don't send me direct emails, use the forum or go to
http://contactez.net/portfolio.html
http://gurleyalabama.contactez.net

Regards

1) Start Outlook
2) Select Tools > Macros > Macros (Alt-F8)
3) Type a new name for the macro then select Create
4) Cut and paste the following code, modify as needed, then run the
macro:

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
I = I + 1
Else
Time2Pause = 30 ' Set pause duration.
Start = Timer ' Set start time.
Do While Timer < Start + Time2Pause 'Timer
Function returns a Single representing the number of seconds elapsed
since midnight
DoEvents ' Yields execution so that the
operating system can process other events
Loop
End If
Loop
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:", "\\buildproductmachine\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 subject of the mail message.
.Subject = "Testing automation Log and Report from AL CM
builder"
'Create 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://TheIngrInternalServer/IngrFolder/Automation/CM/ISO9000GMCMHelp.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("(e-mail address removed)")
.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:\GM\Logs\Release0.log", olByReference)
.DisplayName = "Log Report from Product_Name builder"
End With
'Send the mail message.
.Send
KeepWaiting = False
End With
'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
Else
KeepWaiting = True
End If

ws.RemoveNetworkDrive "X:", True

ERR_Trap:
Select Case Err
Case 0:
Case Else:
MsgBox "dgschnei Error in Outlook VBaProject Macro into Function
IsLogFileThere " & Err '& " - DEBUG SignOn ID: " &
MakeMailMessage.MAPIMessages1.SessionID & Chr(10) & "for: " &
MakeMailMessage.MAPISession1.UserName
End
End Select
End Sub

Thank you for your help.
I appreciate that you took the time to answer me.
I would have preferred not to be present to keep the process going.
Often the build runs at night and we are not here to press the OK
button.
That is why I am trying to have Outlook kick the process after the
log is created, a little bit like a scheduled event... at regular
intervals maybe... The script I have checks for the log file, now I
have to find a way to run the script from outlook every hour or other
intervals...? If the log is present the mail is sent and the
execution of the script will be turned off.
I want to thank you again for your answer any help is always welcomed.
Regards
PS: Please don't send me direct emails, use the forum or go to
http://contactez.net/portfolio.html
http://gurleyalabama.contactez.net


depending on the existence of a file located on another machine that
does not have Outlook installed.
the other is build machine for our products.
machine because of security risk caused by malicious emails and so on...
log is created on the fly by the build automation.
like to launch the Outlook Message on my machine to send an email
message. I created the macro and it works fine (see code below).
I wonder how I can check for the existence of this file using Outlook?
 
Back
Top