Overview
Generating tabular reports from an S7-1200 CPU and a 7-inch HMI panel is one of the most common integration requests on packaging lines, batching skids, and OEM machines. Operators need a CSV that can be opened in Excel for batch traceability, maintenance staff need alarm logs forwarded to engineering, and quality teams need production counters exported as an attachment. TIA Portal exposes several official paths to accomplish this — SMTP email from the CPU via TMAIL_C, HMI-side data logging to USB media, native WinCC report jobs, and FTP transfers — and each method has a distinct firmware, panel-class, and runtime impact profile that must be evaluated before committing to one in a bill of materials.
This reference consolidates the four supported export paths documented in the Siemens support database, including entry 109091876 for WinCC Advanced and the WinCC Unified report-job documentation, wires them to the actual TIA Portal configuration screens, and shows the engineering trade-offs so you can pick the right one for a given machine class.
Prerequisites
Before configuring any of the four export paths, verify that the hardware and software stack is on compatible revisions. Mixing report options across firmware generations is the most common source of unsupported-feature runtime errors.
| Component | Minimum Requirement | Recommended | Notes |
|---|---|---|---|
| CPU firmware | S7-1200 V4.2 for TMAIL_C | V4.4 or later | TMAIL_C ships in the "Communication -> SMTP" library from TIA V13 SP1 onward; TLS variant needs V4.4+ |
| TIA Portal | V13 SP1 | V18 / V19 / V20 | Report designer and report jobs require V14 SP1+ for Comfort Panels; Unified report jobs need V17+ |
| HMI panel | KTP700 Basic (data log only) | TP700 Comfort / MTP700 Unified | Native WinCC reports need Comfort or Unified class; Basic panels only log CSV to USB |
| Storage medium | USB stick <= 32 GB, FAT32 | Industrial SD + SIMATIC HMI memory card | Comfort panels read/write NTFS only from firmware V16 onward via the ET 200SP USB interface |
| DNS / SMTP | Local SMTP relay, port 25 | Authenticated SMTP with STARTTLS, port 587 | TLS 1.2 requires CPU firmware V4.4+ and TIA V15.1+ for the TMAIL_C_SEC variant |
| Network egress | TCP 25 outbound to relay | TCP 587 + DNS over PROFINET | Outbound filtering must allow SMTP from the machine VLAN |
Method Comparison — Email, USB Logging, WinCC Report, and FTP
| Criterion | TMAIL_C Email | HMI Data Log to USB | WinCC Report Job | FTP Server (CPU-side) |
|---|---|---|---|---|
| Trigger source | PLC program | HMI scheduled / event | HMI scheduler | PLC program |
| Output format | CSV, TXT, raw bytes | CSV (RDB-compacted shadow) | PDF, RTF, XLSX (Comfort), PDF (Unified) | CSV / arbitrary |
| Destination | Email recipient | USB / SD / network share | Printer, file system, email | FTP server |
| External software needed | SMTP server | None (operator pulls USB) | None | FTP daemon (IIS, FileZilla, vsftpd) |
| Panel class required | Any (panel not involved) | KTP400 Basic or higher | Comfort / Unified only | Any (panel not involved) |
| CPU load profile | Medium (TCP open/close per send) | None on PLC | None on PLC; medium on panel | Medium (FTP client in PLC) |
| Typical latency to file | Seconds (mail queue dependent) | Immediate on event | Scheduled minute / hour / daily | Seconds |
| Documented in | TIA Portal Help -> SMTP library | WinCC Advanced manual, chapter "Logs" | Siemens Support entry 109091876 | Siemens FTP example project for S7-1200 |
Method 1 — Sending a CSV Report by Email with TMAIL_C
The SMTP block TMAIL_C and its secure variant TMAIL_C_SEC is the most direct path from an S7-1200 to a recipient inbox. The block transmits any byte buffer as an attachment, so the engineering task reduces to formatting the report buffer as a CSV string and triggering the block on a rising edge. TMAIL_C is documented in the TIA Portal online help under "Communication -> SMTP" and is included in every TIA installation starting at V13 SP1.
Hardware and Network Setup
- Connect the S7-1200 PROFINET port to a routable network that can reach the SMTP relay. If the relay is on the office LAN, configure the CPU's IP, subnet mask, and default router under Devices & Networks -> CPU PROFINET interface -> Ethernet addresses.
- Reserve a static DNS entry or hard-code the SMTP server IP.
TMAIL_Cresolves hostnames only on CPU firmware V4.3 or later; earlier firmware requires the IP literal. - Open TCP port 587 (STARTTLS) or 25 (plain) outbound on any firewall between the machine and the relay. Many plant firewalls block 25 by default.
- For
TMAIL_C_SEC, import a CA certificate under Devices & Networks -> CPU Properties -> Security -> Certificate manager. Self-signed certificates require the CA to be added to the trusted root store on the CPU.
Building the CSV Buffer in the PLC
A CSV row is plain ASCII terminated by CR LF (0x0D 0x0A). For a typical shift report, build one DB of type Array[0..N] of Byte and fill it with a series of CHR operations in SCL. A minimal example in Structured Text:
// Shift report CSV builder
"dbReport".len := 0;
FOR i := 0 TO 17 DO
"dbReport".buf[i] := CHAR_TO_BYTE("hdrLine"[i]);
END_FOR;
// Append rows by copying formatted REAL/INT fields
// Insert 0x22 0x3B 0x22 between fields and 0x0D 0x0A at row end
Keep the total buffer under 32 KB for first-pass commissioning. The SMTP library accepts up to roughly 60 KB reliably; above that, chunk the shift into multiple files or compress the buffer before the call. Note that the LEN input on the instance DB must equal the exact number of payload bytes — passing the DB size will result in a partial or padded attachment.
Calling TMAIL_C — Input Map
| Input | Type | Example Value | Description |
|---|---|---|---|
| REQ | BOOL | Rising edge on shift end | Triggers send; idempotent while BUSY=TRUE |
| ID | CONN_OUC | 1 | Connection ID from the Connections tab of the instance DB |
| TO_S | STRING[254] | '[email protected]' | Recipient list, semicolon separated |
| CC | STRING[254] | '[email protected]' | Optional CC |
| SUBJECT | STRING[254] | 'Shift report 2024-05-12' | Subject line, no CRLF |
| TEXT | STRING[254] | 'See attachment.' | Plain-text body |
| ATTACHMENT | VARIANT pointer | "dbReport" | Pointer to the CSV buffer DB |
| FILENAME | STRING | 'ShiftReport.csv' | Filename shown in the mail client |
| USERNAME / PASSWORD | STRING | '[email protected]' | SMTP AUTH credentials |
Wire REQ to a one-shot rising edge from the shift-end logic and evaluate DONE, BUSY, and ERROR / STATUS for diagnostic output. Persist the last STATUS value to a HMI-visible tag for remote diagnostics.
TMAIL_C with TMAIL_C_SEC (introduced in TIA V15.1) and select the certificate slot in the instance DB. Plain SMTP on port 25 is increasingly blocked by upstream providers — prefer authenticated SMTP with STARTTLS on 587.Method 2 — Logging to USB on a KTP / TP Panel
For machines where no IT infrastructure exists, the operator can pull a USB stick from the panel door. This path is independent of the PLC and survives PLC CPU restarts, which is critical for post-mortem analysis after a station power-down.
Configuring the Data Log in TIA Portal
- In the TIA project tree, expand HMI -> Logs -> Data logs and double-click Add new.
- Select storage path USB storage or Network (SMB share).
- Add columns referencing tags from the PLC connection, for example
"DB_Prod".Counter_Good,"DB_Prod".Counter_Reject,"DB_Prod".OEE, and"DB_Prod".BatchID. - Set the log mode to Circular or Segmented. For a shift-aligned export, choose Segmented by time with a 480-minute segment (one per 8-hour shift).
- Define a trigger — either a scheduled trigger (every 60 s) or an event trigger tied to a
ReportReadyPLC tag. - Compile and download the HMI project. The log begins populating at runtime start.
The panel writes a binary RDB file plus a CSV shadow. Plugging the USB stick into a PC reveals both; the RDB can be re-imported into WinCC for offline trend analysis, while the CSV opens directly in Excel with the comma separator (change the separator under Region in the data log properties for European installs).
Operator Workflow on a KTP700
- Insert a FAT32-formatted USB stick into the panel's USB port. Confirm the panel beeps and shows "USB recognized" on the status bar.
- Navigate to the user-defined report screen and press the "Save log" button.
- Confirm the on-screen file path, typically
/media/simatic/HMI_Data/Logs/Shift_001.csv. - Remove the USB and transfer the file to the historian PC via the standard file-share process.
Method 3 — Native WinCC Report (Comfort and Unified)
Native WinCC reports generate a formatted document — PDF on Unified, XLSX/PDF/RTF on Comfort — using the report designer. This is the only path that produces a printable page layout instead of a raw CSV, and is therefore the right choice for batch records and audit documentation.
Adding a Report Template (WinCC Advanced V13 SP1 and later)
Procedure per Siemens Support entry 109091876 — Create a report:
- In the project navigation, right-click Reports and choose Add new report.
- Open the report in the editor; drag Tag table, Alarm view, or Text list objects onto the layout page.
- Open Report properties (right-click the report header) and select the Layout tab. Choose the page size (A4) and orientation (portrait or landscape).
- In the Output tab, choose the printer, file path, or email destination.
- Save and download the HMI project to the panel.
Creating a Report Job (WinCC Unified V17 and later)
Procedure per the WinCC Unified — Creating a report job documentation:
- Open the Unified HMI project. Under Reports -> Report tasks, add a new task.
- Assign the report template created in the report editor.
- Select the Trigger: Time, Event, or Variable change.
- Define the Output: file-system path on the Unified runtime (e.g.
/home/industrial/reports/), printer, or email via the configured SMTP user. - For automatic emailing, the Unified runtime reads the SMTP user from Settings -> Mail. Configure username, password, host, port, TLS, and sender before testing.
- Activate the report task and observe the status under Diagnostics -> Report queue.
Exporting a Report Manually
On the HMI runtime, an operator presses a configured button bound to the system function PrintReport (Comfort) or the ExportReport script function (Unified). The panel prompts for a destination; on Unified, the file is exported to the configured storage path and can be retrieved via the panel's WebDAV interface on port 443.
Method 4 — FTP Push from the S7-1200
When the destination is a plant historian rather than an inbox, push the CSV over FTP. The S7-1200 acts as an FTP client using the FTP_CMD block from the same communication library.
- Configure the FTP server (Windows IIS, FileZilla Server, or Linux vsftpd) with a write-only user for the S7-1200.
- Import the
FTP_CMDinstance DB and setID,CONNECTION_TYPE := FTP, and the remote path. - Use the same CSV buffer built for Method 1; the
FTP_CMDupload command accepts aVARIANTpointer to a byte DB. - Schedule the upload at shift end via a one-shot from the shift bit, and persist the result code to a HMI-visible diagnostic tag.
FTP passes credentials in cleartext. If the historian is outside the OT zone, terminate the session at a firewall and prefer SFTP from a Unified panel instead. Plain FTP should be limited to isolated engineering VLANs.
CSV Format and Excel Compatibility
Excel auto-detects field separators from the regional locale list. On a German Windows install, ; is the default separator; on US English, it is ,. To keep a single file usable in both environments, embed the separator declaration on the first line and add a leading UTF-8 BOM (0xEF 0xBB 0xBF) so Excel reads the file as UTF-8 unconditionally:
sep=;
"Timestamp";"Counter_Good";"Counter_Reject";"OEE"
"2024-05-12 06:00:00";1234;12;0.91
"2024-05-12 06:01:00";1244;12;0.91
This pattern is consumed natively by Excel 2016+ and LibreOffice Calc 7+ without an import wizard. For a Word-style report, generate an RTF template from a Comfort panel report job instead — RTF preserves paragraph and table formatting when opened in Word.
Verification Procedure
- Build check: compile the project (Ctrl+B) in TIA Portal. Watch for warnings about SMTP library version mismatches; clear all warnings before download.
-
Download: connect to the target CPU and the HMI panel. After the CPU download, force the shift-end bit and observe the rising edge on
TMAIL_C.REQ. - Mail check: open the recipient mailbox; verify the subject, body, and that the attachment opens without a "file format may be incorrect" warning. Verify the byte count by re-saving and comparing file size in mail client and DB.
- USB check (Method 2): insert a USB stick, trigger a log entry, remove the stick, open the file in Excel; confirm columns and decimal separator.
- Report job check (Method 3): open the Unified diagnostics page, confirm the report task status transitions to Completed; download the PDF via WebDAV.
- FTP check (Method 4): list the remote folder and download the file; compare MD5 against the local buffer's hash.
Troubleshooting Matrix
| Symptom | Likely Cause | Indicator (TMAIL_C / Runtime) | Remediation |
|---|---|---|---|
| Mail not delivered | DNS resolution failed | STATUS indicates WSAHOST_NOT_FOUND class | Hard-code SMTP IP, or check PROFINET DNS settings under CPU properties |
| Mail rejected at relay | SMTP auth rejected | STATUS indicates AUTH failure code | Verify username/password; check relay requires AUTH LOGIN vs. PLAIN; check that the relay accepts the client IP |
| Mail accepted, attachment garbled | Length mismatch | DONE=TRUE, but Excel shows trailing nulls | Set ATTACHMENT.LEN to the exact byte count, not the DB size |
| USB log not visible | Wrong file system | — | Reformat to FAT32; Comfort >= V16 supports NTFS only with ET 200SP USB |
| Report job stuck at "Pending" | Unified SMTP user not configured | Runtime log: SMTP_HOST_EMPTY | Open Settings -> Mail on the Unified runtime and complete the host field |
| TMAIL_C compile error "block not found" | SMTP library not installed | — | Options -> Manage Libraries -> import "Communication -> SMTP" |
| FTP upload rejected | Remote path missing | FTP_CMD returns 5xx reply code | Pre-create the folder or grant user create rights |
| HMI panel does not recognize USB stick | Partition scheme GUID (GPT) | — | Reformat as MBR with single FAT32 partition |
| TLS handshake fails | CPU firmware older than V4.4 | TMAIL_C_SEC STATUS indicates handshake error | Upgrade firmware or fall back to plain SMTP on port 25 within plant only |
| Mail sent but recipient cannot open | CSV uses locale separator incompatible with recipient Excel | — | Embed sep=; on first line and use UTF-8 BOM |
Field-Commissioning Checklist
- CPU firmware version verified against the TIA project (compare Online -> Diagnostics -> CPU -> Firmware).
- SMTP credentials tested with a desktop mail client (Outlook, Thunderbird) before binding to the PLC.
- Network firewall rules documented in the network diagram with rule ID, source, destination, and port.
- USB stick model on the Bill of Materials; industrial-grade SanDisk or Siemens 6ES7648-0DC50-0AA0 recommended.
- Report templates version-controlled with the HMI project; rebuild, do not edit in production.
- Backup procedure for report archives — RDB files can be replayed in WinCC if the original CSV is corrupted.
- Diagnostic tags mapped to a maintenance screen showing last STATUS, last DONE timestamp, and last error code.
- Time synchronization active on CPU and panel (NTP or CP-side), so timestamps in the CSV match the historian's reference clock.
FAQ
Which S7-1200 firmware first supports TMAIL_C?
TMAIL_C is available on S7-1200 CPUs from firmware V4.2 onward, included in the "Communication -> SMTP" library that ships with TIA Portal V13 SP1. For TLS, use TMAIL_C_SEC on V4.4+ and TIA V15.1+.
Can a 7-inch Basic panel (KTP700 Basic) generate a formatted PDF report?
No. KTP Basic panels only export raw CSV logs to USB; the native report designer (PDF/XLSX/RTF output) requires a Comfort-class or Unified MTP panel.
What is the maximum attachment size for TMAIL_C?
The block does not impose a documented hard limit, but the SMTP relay typically accepts up to 25 MB. Above 32 KB the build time of the SMTP body becomes noticeable on the CPU; consider compressing the buffer or splitting the shift into multiple files for large archives.
Do I need an FTP server if I already email the report?
Not for an end user. FTP is useful when the destination is a historian or MES that polls a known directory rather than processing inbound mail. For consumer-grade networks, prefer email or SFTP from a Unified panel.
Where is the report designer in TIA Portal V20?
Project navigation -> HMI device -> Reports. Double-click "Add new report" to create a template, then add a report task under "Report tasks" to schedule it on a Unified runtime. See Siemens Support entry 109091876 and the WinCC Unified report-job documentation.