Description
Sends a MAPI message.
Syntax
status = MAPISendMail([session][, parent][, flags], message)
Parameters
The MAPISendMail function has the following parameters.
| Parameter | Description |
|---|---|
| session | Contains a MAPI session handle returned by MAPILogon. If not specified a system default session will be initiated, if possible, or a sign-in dialog box will be displayed. In any case, MAPI will return to its previous state upon completion of the function. |
| parent | Contains the name of an OpenInsight parent window. If not specified any dialog box displayed will be application modal. |
| flags | Contains information about how the message should be sent. It could be MAPI_LOGON_UI$, MAPI_NEW_SESSION$, MAPI_DIALOG$, or a combination of these flags.
The insert record MAPI_EQUATES contains these flags. You may combine flags by adding them together with an addition sign (+). |
| message | Contains the record for the message which is to be sent. The message record structure is detailed in the following table. The from and date fields and the MAPI_UNREAD$ and MAPI_SENT$ flags are ignored when sending a message. |
After the function completes successfully the message will be delivered to the recipients listed in the given message record or selected through the send message dialog.
Use the MAPI_EQUATES insert record for access to the values in the following table.
| Column position | Name | Purpose |
|---|---|---|
| 1 | subject | The subject of the message. |
| 2 | from | The sender of the message. |
| 3 | To | @VM-delimited list of the message's To: recipients. |
| 4 | Cc | @VM-delimited list of the message's CC: recipients. |
| 5 | Bcc | @VM-delimited list of the message's BCC: recipients. |
| 6 | date | The date the message was received. |
| 7 | Text | The text of the message. |
| 8 | Type | The type of the message. |
| 9 | Flags | The attributes of the message. It could be MAPI_UNREAD$, MAPI_RECEIPT_REQUESTED$, MAPI_SENT$, or a combination of these flags.
The insert record MAPI_EQUATES contains these flags. You may combine flags by adding them together with an addition sign (+). |
| 10 | Files | @VM-delimited list of the names of files to be attached to the message. |
| 11 | paths | @VM-delimited list of the paths to files to be attached to the message. |
| 12 | positions | @VM-delimited list of the positions within the text of files to be attached to the message. |
Returns
1 for successful execution or 0 for failure.
If function execution fails, you can retrieve a text error message by calling the Get_Status function. For example, to display an error message on the screen, include the following error handling routine in your code:
Get_Status(ErrMsg) Msg(@window, ErrMsg)
See also
Get_Status(), MAPISendDocuments()
Example
Subroutine DemoMAPISendMail(var) *Create a new message and send it to Alice $INSERT MAPI_EQUATES Declare Function MAPISendMail Declare Subroutine Msg, Get_Status flags = MAPI_LOGON_UI$+MAPI_DIALOG$ message = "" message<POS_SUBJECT$> = "MAPI Demo" message<POS_TO$> = "Alice Smith" message<POS_TEXT$> = "This is a test of the emergency..." message<POS_FLAGS$> = MAPI_RECEIPT_REQUESTED$ if MAPISendMail(0, 0, flags, message) then Msg(@window, "Message successfully sent") end else Get_Status(display) Msg(@window, display) end return