Share this page

# smtp_send_mail_ex

Simple Mail Transfer Vuser Functions (SMTP)

Sends an SMTP mail message for a specific session.

    int smtp_send_mail_ex( SMTP *ppsmtp,char *transaction, char *RecipientTo, [char *RecipientCC,][char *RecipientBCC,] char *Subject,[char *From,][char *ContentType, < char *charset,>]char *MAILOPTIONS, char *MAILDATA, LAST );

ppsmtp | A session identifier.
transaction | A transaction name for this step in quotes. To instruct VuGen not to create a transaction for this step, use an empty string, "".
RecipientTo | The name of the mail recipient(s) in the format: `"To=`email_address1`", "`email_address2`", . . .`
RecipientCc | The name of the CC recipient(s) in the format: `"CC=`email_address1`", "`email_address2`", . . .`
RecipientBCC | The name of the BCC recipient(s) in the format: "`BCC=`email_address1, email_address2, ..."
Subject | The subject of the mail in the following format: `"Subject=`my_subject`"`
From | An e–mail address representing the reverse path for the mail, that is, the sender. If this argument is not passed the From field is generated from the user name and server. "From:=user@server"
ContentType charset | A content type in the following format: "ContentType=multipart/alternative". The default is `multipart/mixed.` If the content type is `text/plain`, you can also specify the character set. The value must be quoted. Use the backslash to prevent the quote marks being interpreted as the end of the argument. If no character set is specified, the default is "`us–ascii`". For example: `"ContentType=`text/plain`",``"charset=`\"iso–8859–4\"`",`
MAILOPTIONS | The mail client configuration options and settings in the following format: `"MAILOPTIONS", "`Option1:value`", ."`Option2:value`" ,. .` For a partial list, see Mail Options.
- MAILDATA | The mail data provided as mail content or as a file attachment. Specify mail content in the following format: `"MAILDATA", "`MessageText=...`", "`MessageBlob=...`" .` Specify as a .dat file attachment, using `AttachRawFile`. For example:"AttachRawFile= `mailnote1.dat`" The .dat file can contain either the body of the email, or an attachment that is encoded with base64. For mail clients that support HTML format, you can include HTML tags and HTTP headers. Example of DAT file containing body text: Copy code
      Content-Type: text/plain; charset=us-ascii
      Content-Transfer-Encoding: 7bit

      Hello person1,
      Nice to talk to you
      --
      Best regards,
      person2
  Example of DAT file containing binary file attachment encoded in base64: Copy code
      Content-Type: application/pdf;
      name="ExampleDocument.pdf"
      Content-transfer-encoding: base64
      Content-Disposition: attachment;
      filename=" ExampleDocument.pdf"

      JVBERi0xLjMNCjMgMCBvYmoNCjw8DQovUHJvZHVjZXIgKFBERlhDIExpYnJhcnkgXCh2ZXJz
      aW9uIDIuNVwpLikNCi9PU0luZm8gKHZpczogMTQ4OyB2ZXI6IDUuMTsgYm46IDAwMDAwYTI4
      OyBwbGF0ZjogMjsgQ0RTOiBTZXJ2aWNlIFBhY2sgMSkNCi9DcmVhdGlvbkRhdGUgKEQ6MjAw
      NTAzMzExNzIzNTEtMDUnMDAnKQ0KPj4NCmVuZG9iag0KNCAwIG9iag0KPDwNCi9MZW5ndGgg
      MTUzDQovRmlsdGVyIFsvRmxhdGVEZWNvZGVdDQo+Pg0Kc3RyZWFtDQp42hXKIQ6DQBSE4b3T
      uwEeicbNFbAojkAy...
LAST | A marker indicating the end of the argument list.

The smtp_send_mail_ex function sends a mail message using the SMTP server for the specified session.

This function is for use with multiple sessions. For global sessions, use the smtp_send_mail function, which leaves out the session identifier.

## Return Values

If this function succeeds, it returns LR_PASS. Otherwise, it returns LR_FAIL.

## Parameterization

All arguments of this function of the type char, can be parameterized with standard parameterization.

## Example

In the following example, the smtp_send_mail_ex sends an SMTP mail message via MS Outlook.

Copy code

    Action()
    {
        smtp_logon_ex(&ppsmtp, "Logon",
            "URL=smtp://user0001t@techno.merc–int.com",
            "CommonName=Smtp Test User 0001",
            LAST );
        smtp_send_mail_ex(&ppsmtp, "SendMail",
            "To=williamprice@mansfield.park.co.uk",
            "Cc=fannyprice@mansfield.park.co.uk",
            "Bcc=susanprice@mansfield.park.co.uk",
            "From=edmundbertram@mansfield.park.co.uk",
            "Subject=",
            "ContentType=text/plain;",
            "charset=\"iso–8859–4\"",
            MAILOPTIONS,
                "X–Priority: 3",
                "X–MSMail–Priority: Normal",
                "X–Mailer: Microsoft Outlook Express 5.00.2919.6700",
                "X–MieOLE: Produced By Microsoft MimeOLE V5.00.2919.6700",
            MAILDATA,
                "MessageText=This is a simple mail\r\n",
            LAST );
        smtp_logout_ex(&ppsmtp);
        return 1;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: