Start an email using default email programΒΆ

sendmail()

Start an email


SYNTAX

sendmail(record_id)

Opens the default email program on the host computer and starts an email with an optional set of attached files. This function works only on Microsoft Windows operating systems.

The record_id argument is the identifier of a !record structure with some or all of the following fields:

!record record_id {
     FileNames,,a80[5]
     Subject,,a80
     Body,,a80[10]
     To,,a40
     Cc,,a40[2]
     Bcc,,a40
}

The field sizes given here are just examples; each field can be any alphanumeric size. Note also that any dimension can be used for the array fields Filenames, Body, To, and Cc.

The Body field can be a long text (packed) field, as in the example code below, or non-packed as above. If non-packed, each element of the body text is assigned separately; if packed a single string should be assigned (as below). Note the use of chr(0x0d) + chr(0x0a), which causes the following text to start on a new line.

All non-blank elements of the Filenames field are the names of files to attach. The filenames may have full or relative pathnames. Sculptor converts the pathnames to standard full pathnames before passing them to the email program.

Note

New in version 6.3.1: New fields have been added to the !record structure.

Flags can be used to overwrite the default MAPI_LOGON_UI | MAPI_DIALOG value used in the Win32 MAPISendMail function.

Orig may be used to specify the origin from where the email is sent (it depends on the configured email client to honor this value).

!record record_id {
  Flags,,i4
  Orig,,a40
}

The function returns 0 if successful, or a non-zero value if the default email program cannot be started or a specified attachment does not exist.

See SCULPTOR\demo\misc\sendmail.f for an example program.


EXAMPLES

Prepare an email with two attachments and show the email client with the email prepared to be sent:

!temp Status,,i4

!record MailRec {
     To,,a40
     Filenames,,a80[2]
     Subject,,a80
     Body,,a80[5],,p
}
     cleardata MailRec
     MailRec.To = "info@sculptor.co.uk"
     MailRec.Subject = "Sculptor Totally Rocks!"
     MailRec.Body = "Your product is outstandingly good." \
          + "I'm attaching some files of suggestions for enhancements." + chr(0x0d) + chr(0x0a)\
          + "Hoping to hear from you soon!"
     MailRec.FileNames[1] = "sculplist1.txt"
     MailRec.FileNames[2] = "/usr/lucien/sculppic.jpg"

     tmp.Status = sendmail(MailRec)
     info "Sending 2 files - return status is " + tostr(tmp.Status)

Send automatically an email with the default email client account:

!temp Status,,i4

!record MailRec {
     To,,a40
     Subject,,a80
     Body,,a80[5],,p
     Flags,,i4
}
     cleardata MailRec
     MailRec.To = "info@sculptor.co.uk"
     MailRec.Subject = "Sculptor Totally Rocks!"
     MailRec.Body = "Your product is outstandingly good." \
          + "I'm attaching some files of suggestions for enhancements." + chr(0x0d) + chr(0x0a)\
          + "Hoping to hear from you soon!"

     . Force the mail to be sent directly
     MailRec.Flags = 0

     tmp.Status = sendmail(MailRec)
     info "Send email - return status is " + tostr(tmp.Status)