docs

Home Getting Started Browse by Category All functions

Send a Batch of Emails from CSV

vuMailKit can read a CSV file and queue one outgoing message for each valid row.

This is useful when you already have message data in rows, such as notices, reminders, or invoice emails generated by your application.

If you are just getting started, prove one normal vuSendMailWait() send first. Then move to CSV sending after the stored profile and ordinary send path are working.

CSV field order

Each input row must contain seven fields in this order:

FROM,TO,CC,BCC,SUBJECT,BODY,ATTACH

The CSV parser supports quoted fields, so commas can appear inside quoted subject or body text.

Example CSV file

"","customer1@example.com","","","Service reminder","Your service is due next week.",""
"Billing <billing@example.com>","customer2@example.com","","","Invoice attached","Please see the attached invoice.","C:\Invoices\Invoice1002.pdf"
"Support","customer3@example.com","","","Support follow-up","Thank you for contacting support.",""

A blank FROM field uses the saved/default profile sender. A FROM value that is only a display name, such as Support, uses that display name with the saved/default profile sender address.

Send the CSV file

Result      LONG
CsvFile     CSTRING(260)
DefaultAtt  CSTRING(260)

CsvFile    = 'C:\Mail\Outbox.csv'
DefaultAtt = ''

Result = vuSendMailFromFile(CsvFile, DefaultAtt)
IF Result <> 1
  MESSAGE('CSV send failed: ' & vuMailLastError())
END

vuSendMailFromFile() returns 1 when at least one valid row was queued. Blank lines and invalid rows are skipped. If no valid rows remain, the function returns 0.

Default attachment

The second parameter supplies a default attachment path or attachment list for rows where the CSV ATTACH field is blank.

CsvFile    = 'C:\Mail\Outbox.csv'
DefaultAtt = 'C:\Mail\StandardTerms.pdf'

Result = vuSendMailFromFile(CsvFile, DefaultAtt)

Attachments in either the CSV row or the default attachment parameter may be blank, a single full path, a comma-separated or semicolon-separated list, or a wildcard mask such as C:\Mail\Statements*.pdf.

Body text and line breaks

CSV body fields can contain ordinary body text. When the body is simple text, write the body as text. Do not add HTML tags unless you intentionally want an HTML body.

For long or formatted bodies, it is often easier to put the body in an external text or HTML file and put that file path in the BODY column. vuMailKit uses the same body-file loading behavior as vuSendMail() and vuSendMailWait().

Sent-mail CSV log is different

Do not confuse this input CSV file with the sent-mail CSV/activity log selected by vuSetMailLog() or vuLogSetFile().

Home Getting Started Browse by Category All functions