Mapi Class [AX 2012]
The Mapi class enables email to be sent, received, and managed in most major mail systems, such as Microsoft Exchange–based systems, Microsoft Outlook Express, and Lotus CCMail.
| Method | Description | |
|---|---|---|
| cancelTimeOut | Cancels a previous method call to the setTimeOut method. (Inherited from Object.) |
| deleteMail | Removes the specified message from the message store. |
| equal | Determines whether the specified object is equal to the current one. (Inherited from Object.) |
| finalize | |
| findNext | Finds the first or next message in the message store. |
| getTimeOutTimerHandle | Returns the timer handle for the object. (Inherited from Object.) |
| handle | Retrieves the handle of the class of the object. (Inherited from Object.) |
| logoff | Lets you log off the mail system. |
| logon | Logs on to the mail system by using the specified profile and password. |
| new | Initializes an instance of the Mapi class. (Overrides the new Method.) |
| notify | Releases the hold on an object that has called the wait method on this object. (Inherited from Object.) |
| notifyAll | Releases a lock on the object that was issued by the wait method on this object. (Inherited from Object.) |
| objectOnServer | Determines whether the object is on a server. (Inherited from Object.) |
| owner | Returns the instance that owns the object. (Inherited from Object.) |
| readMail | Retrieves a message from the message store. |
| resolveName | Transforms the message recipient's name, as entered by a user, to an unambiguous address list entry. |
| saveMail | Saves a message to the message store. |
| sendMail | Sends a message to the specified recipients. |
| setTimeOut | Sets up the scheduled execution of a specified method. (Inherited from Object.) |
| status | Retrieves the status of the last Mapi operation. |
| toString | Returns a string that represents the current object. (Inherited from Object.) |
| usageCount | Returns the current number of references, that is, the value of the reference counter, that the object has. (Inherited from Object.) |
| wait | Pauses a process. (Inherited from Object.) |
| xml | Returns an XML string that represents the current object. (Inherited from Object.) |
Together with the other Mapi classes, MapiMessage, MapiRecipDesc, and MapiFileDesc, this class lets you specify multiple recipients, file attachments, message text, and a subject.
The easiest approach is to set up a working mail client on the machine, and make sure that this works correctly order by sending and receiving a few email messages.
Flags for the Mapi methods are located in the Mapi macro. You include this macro in code where you use the Mapi classes together with the #MAPI statement.
The following example shows how to send an email message by using this class.
static void example()
{
#Mapi
Mapi m = new Mapi();
MapiMessage msg = new MapiMessage();
MapiRecipDesc recip = new MapiRecipDesc();
// Set up the recipient.
recip.Name("someone");
recip.RecipClass(#MAPI_TO);
msg.setRecipNo(1,recip);
// Log on using default profile.
m.Logon("","",#MAPI_USE_DEFAULT);
// Send the mail, and allow the user to modify the
// Subject, Text and Recipients in the Send Mail Dialog.
m.SendMail(msg,#MAPI_DIALOG);
// Log off.
m.Logoff();
}