Exporting a Host Screen to an Outlook Email

Exporting a Host Screen to an Outlook Email

Flex Terminal Emulator allows you to export the contents of a host screen directly into a new Microsoft Outlook email using a macro. This is useful for quickly sharing or documenting screen data.


Overview

The macro performs the following actions:
  • Captures all visible text from the current host screen
  • Creates a new Outlook email message
  • Inserts the captured screen content into the email body
  • Displays the email for review before sending

Sample Macro Code

The example below demonstrates how to export the current screen to an Outlook email:
  1. Sub Main()

  2.   Dim outobj, mailobj

  3.   ' Determine the screen size
  4.   nRow = FlexScreen.Rows
  5.   nCol = FlexScreen.Columns   

  6.   ' Create Outlook objects
  7.   Set outobj = CreateObject("Outlook.Application")  
  8.   Set mailobj = outobj.CreateItem(olMailItem)   

  9.   ' Capture screen text line by line
  10.   For i = 1 to nRow
  11.     strText = strText & FlexScreen.GetText(FlexScreen.Position(i, 1), nCol)
  12.     strText = strText & vbCRLF
  13.   Next

  14.   ' Populate the email
  15.   With mailobj
  16.     .Subject = "Flex Terminal Emulator Screen"
  17.     .Body = strText
  18.     .Display
  19.   End With

  20.   ' Clean up
  21.   Set outobj = Nothing  
  22.   Set mailobj = Nothing  

  23. End Sub

How It Works

  • The macro retrieves the number of rows and columns from the current host screen.
  • It loops through each row, capturing the full width of text.
  • The captured content is assembled into a single string with line breaks.
  • A new Outlook email is created and populated with the screen data.
  • The email is displayed so you can review, edit, and send it.

Notes

  • The email body uses the default font configured in Outlook.
  • If the screen formatting appears misaligned, change the font to a fixed-width (monospaced) font such as:
    • Courier New
    • Consolas

    You can do this by selecting all text in the email (press
    Ctrl+A) and choosing a different font.

Saving and Using the Macro

To use this macro:
  1. Copy the code into the Flex Terminal Emulator macro editor, or any text editor (such as Notepad).
  2. Save the file with an .ams extension.
  3. Place the file in the Macros subfolder of your Flex Terminal Emulator user directory.
  4. Run the macro from within Flex Terminal Emulator.

Notes
This method provides a quick and efficient way to capture and share host screen data via email.

    • Related Articles

    • Exporting Host Screen Data to Excel Using a Macro

      Flex Terminal Emulator allows you to automate the extraction of data from host screens and export it directly into an Excel spreadsheet using a macro. This approach is useful for collecting structured data across multiple screens. Overview A macro ...
    • Exporting a Host Screen to Microsoft Word

      Flex Terminal Emulator allows you to export the contents of a host screen directly into a Microsoft Word document using a macro. This is useful for documentation, reporting, or sharing screen data. Overview The macro performs the following actions: ...
    • Supported Host Code Pages in Flex Terminal Emulator

      Flex Terminal Emulator supports a range of host code pages to ensure compatibility with different regional and language requirements. Available Host Code Pages The following host code pages are supported: 037 – US / Canada 273 – Austria / Germany 277 ...
    • Recording a Login Macro and Running It Automatically at Startup

      Flex Terminal Emulator allows you to automate the login process by recording a macro and configuring it to run each time a session connects to the host. Step 1: Record a Login Macro Follow these steps to capture your login sequence: Open the Flex ...
    • Maximizing the Host Screen Area in Flex Terminal Emulator

      To increase the visible host screen area in Flex Terminal Emulator, you can hide or minimize certain interface elements. The following options can help you optimize screen space. Hide the Status Bar The Status Bar is displayed at the bottom of the ...