PASSPORT Knowledge Base
Macros

Date Published: March 15, 2010

Title

Email Host Screen From Emulator

Macro Type

.ZMC

Description

This macro will email the current PASSPORT screen to one or more user provided email addresses using Microsoft Outlook. A temporary file is used to store the contents of the screen (C:\Program Files\PASSPORT\temp.txt by default), which the user must have write access to. When prompted, the user will input one or more email addresses separated by semi-colons then click the OK button or the Enter key on the keyboard. Each time the macro is run this file is overwritten with the contents of the new screen.

Sample Code


' This macro emails the current screen to the user provided email address(es).
Sub ZMain()
' Allocate the local variables for this PASSPORT macro
   Dim nRow, nCol
   Dim nScreenSize
 
' Determine the actual screen size (number of rows and columns)
   nScreenSize = GetScreenSize ()
   Select Case nScreenSize
      Case 2000
 nRow = 25
 nCol = 80
      Case 2560
         nRow = 32
         nCol = 80
      Case 3168
         nRow = 24
         nCol = 132
      Case 3300
 nRow = 25
 nCol = 132
      Case 3440
         nRow = 43
         nCol = 80
      Case 3564
         nRow = 27
         nCol = 132
      Case Else
         nRow = 24
         nCol = 80
   End Select
 
' Name of the temp file (user must have write permissions)
strTextFile = "C:\Program Files\PASSPORT\temp.txt"
 
' Write the current screen contents to the above temporary file 
WritePSToFile strTextFile,1,1,nRow,nCol
 
' Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
' Open the text file - strScreen will now contain the current PASSPORT screen
strScreen = objFSO.OpenTextFile(strTextFile, 1).ReadAll
 
' Get the email address(es) to send to
strEmail=MsgBoxGetInput("Please enter the email address to send to:" & vbCRLF & vbCRLF & "(Multiple addresses should be separated by semicolons.)")
 
If strEmail <> "" Then
      ' Create a new Microsoft Outlook message containing the contents of the current PASSPORT screen
      Set MyApp = CreateObject("Outlook.Application")
      Set MyItem = MyApp.CreateItem(0) 'MailItem
            With MyItem
            .To = strEmail
            .Subject = "PASSPORT Host Screen" 'Modify this text string to change the email subject field
            .Body = strScreen 
            End With
      MyItem.Send
      MsgBox "The current PASSPORT screen has been succesfully sent to " & strEmail & ".", 64, "Congratulations!"
End If
 
'Cleanup the file system object
Set objFSO = Nothing
 
End Sub

More Information