Share this page

# mapi_send_mail_ex

MS Exchange Server Functions (mapi)

Sends an MAPI mail message for a specific session.

    int mapi_send_mail_ex( MAPI *ppmapi, char *transaction, char *To, [char *CC,] [char *BCC,] [char *Subject,] [char *Type,] [char *Body,] [ATTACHMENTS,] LAST );

ppmapi | A session identifier.
transaction | A transaction name for this step in quotes. To instruct VuGen not to create a transaction for this step, use a NULL string, "".
To | The name of the mail recipient(s) in the format: `"To=`email_address1`,` email_address2`, . . ."`
CC | The name of the CC recipient(s) in the format: `"CC=`email_address1`,` email_address2`, . . .".`
BCC | The name of the blind recipient(s), BCC, in the format: `"BCC=`email_address1`", "`email_address2`", . . .`
Subject | The subject of the mail in the following format: `"Subject=my_subject"`
Type | The type of mail message: `"Type=`mail_type`"`
Body | The mail content in the following format: `"`Body=xyz abc...`"`
ATTACHMENTS | The files to be attached to the mail message in the following format: `"ATTACHMENTS", "File=path1\file1", [Position=`pos1,`] "ENDITEM", "File=path2\file2", [Position=`pos2,`] "ENDITEM"`Position indicates the character offset within the body of the message. Position=5 places the attachment after 5 characters.
LAST | A marker indicating the end of the argument list.

The mapi_send_mail_ex function sends a mail message using the MAPI server for the specified session.

If attachments are specified and they are not found, the mail is not sent.

This function is for use with multiple sessions. For global sessions, use the mapi_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 mapi_send_mail_ex sends several types of mail messages.

    //Send a simple mail message

        mapi_send_mail_ex(&mapi,"SendMail",
                "To=user0001t@techno.merc-int.com",
                "Subject=<GROUP>:<VUID> @ <DATE>",
                "Body=Test Message! Please ignore.",
                LAST );

    //Send a Sticky Note message

        mapi_send_mail_ex(&mapi,"SendMail",
                "To=user0001t@techno.merc-int.com,user0010t@techno.merc-int.com",
                "Cc=user0002t@techno.merc-int.com",
                "Bcc=user0003t@techno.merc-int.com",
                "Subject=<GROUP>:<VUID> @ <DATE>",
                "Type=IPM.StickyNote",
                "Body=Please update your profile today.",
                LAST );

    //Send mail with Attachments

        mapi_send_mail_ex(&mapi,"SendMail",
                "To=user0001t@techno.merc-int.com",
                "Subject=Attach Test @ <DATE>",
                "Body=Test Message!",
                "ATTACHMENTS",
                    "File=E:\\QA\\for_dcom\\vbj_readme.txt", "ENDITEM",
                    "File=E:\\QA\\for_dcom\\vbj_readme.txt", "ENDITEM",
                LAST );

    //Send mail with Attachment within body

        mapi_send_mail_ex(&mapi, "Mail1",
            "To=user0001t@techno.merc-int.com",
            "Subject=This is a my subject ",
            "Body=This is a sample mail. This is the outfile.",
            "Type=IPM.StickyNote",
            "ATTACHMENTS",
            "Name=AutoExec.bat", "File=c:\\autoexec.bat", "Position=5", "ENDITEM",
            "Name=Outfile.txt", "File=c:\\tmp\\outfile.txt", "Position=30", "ENDITEM",
            LAST );

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