Sie sind auf Seite 1von 4

-1-

VFP Extended MAPI Documenation:


Function EMCreateMessage()

Signature: EMCreateMessage(cSubject, cBody, nImportance)

Parameters:

cSubject - subject line of the email

cBody - body of the email

nImportance - level of importance for the email - valid values for this parameter are as follows:

0 = Low Importance
1 = Normal Importance
2 = High Importance

Return Value:

Logical - indicating whether the message was successfully created - .T. for success and .F. for failure

Remarks:

This function creates the email message that is going to be sent and should be called first before adding
recipients and/or attachments.

Function EMCreateMessageEx()

Signature: EMCreateMessageEx(cSubject, cHtmlOrRtfBody, nImportance)

Parameters:

cSubject - subject line of the email

cHtmlOrRtfBody - body of the email formatted in HTML or RTF

nImportance - level of importance for the email - valid values for this parameter are as follows:

0 = Low Importance
1 = Normal Importance
2 = High Importance

Return Value:

Logical - indicating whether the message was successfully created - .T. for success and .F. for failure

Remarks:

This function creates the email message that is going to be sent and should be called first before adding
recipients and/or attachments. This function is an advanced version of EMCreateMessage providing for either
HTML or RTF within the body of the email. Ensure that the cHtmlOrRtfBody parameter contains complete HTML
or RTF as shown in the example above. In short, the opening and closing tags are required as they are used to
determine what format was used for the body.
-2-

Function EMAddRecipient()

Signature: EMAddRecipient(cRecipientEmailAddress, nRecipientType)

Parameters:

cRecipientEmailAddress - subject line of the email

nRecipientType - defines the type of recipient to be added - valid values for this parameter are as follows:

0 = Original
1 = To
2 = CC
3 = BCC

Return Value:

Logical - indicating whether the recipient was successfully added - .T. for success and .F. for failure

Remarks:

This function should be called after the EMCreateMessage function.

Function EMAddAttachment()

Signature: EMAddAttachment(cFileName)

Parameters:

cFileName - full path and file name of the attachment to be added

Return Value:

Logical - indicating whether the attachment was successfully added - .T. for success and .F. for failure

Remarks:

This function should be called after the EMCreateMessage function.

Function EMSend()

Signature: EMSend([lSendImmediately])

Parameters:

lSendImmediately - .T. or .F. value indicating whether the email message should be sent immediately or remain
in the Outbox (see disclaimer in Remarks below)
-3-

Return Value:

Logical - indicating whether the email was successfully placed into the email client send queue (outbox) - .T. for
success and .F. for failure

Remarks:

This function should be called after the EMCreateMessage function. Also, it is important to note that just
because the file has been placed to the outbox of the email client and is waiting to be sent does not mean that
the email will be immediately sent. When the email actually gets sent (right away or after a certain delay) is
dependent on the user-defined settings in the email client for sending email that is sitting in the send queue. If
you wish to send the email(s) in the outbox immediately (regardless of user settings) you can pass .T. for the
lSendImmediately parameter. The email(s) in the outbox can be sent immediately regardless of whether or not
the user currently has their email client open.

Be aware that the autosend feature provided by the lSendImmediately parameter does not work for Outlook
2002-2003. If anyone knows a way around this limitation I would appreciate it if you would contact me. For more
details on this limitation see http://support.microsoft.com/kb/317412.

Function EMDisplay()

Signature: EMDisplay()

Parameters: None

Return Value:

Logical - indicating whether the user sent the email from the compose window or cancelled the operation by
clicking the close button - .T. for sent and .F. for cancelled.

Remarks:

This function should be called after the EMCreateMessage function. Rather than submitting the email directly to
the outbox, this function allows you to show the client's email composition window. The email can be displayed
whether or not the user has their email client open.

Function EMBindEvent()

Signature: EMBindEvent(nEvent)

Parameters:

nEvent - numeric value indicating the type of MAPI Notification Event to watch for. The following is a list of
possible values:
Critical Error = 1
New Email Arrival = 2
Object Created = 4
Object Deleted = 8
Object Modified = 16
Object Moved = 32
Object Copied = 64
Search Complete = 128
Table Modified = 256
Status Object Modified = 512
Reserved For MAPI = 1024
Extended = 2048

Return Value:
-4-

Logical - indicating whether the event was successfully bound - .T. for success and .F. for failure

Remarks:

This function is most easily understood by running the example provided. When the bound event is fired it sends
a message to the _VFP window that can easily be bound to using Visual FoxPro's BindEvent. Information
regarding the notfication event that fired can be extracted from the LPARAM parameter. This is just a beginning.
Eventually the library will provide other methods of easily extracting the information from all the pointers and
structures. For now I would like developers to get a feel for how this works.

It should be noted that for now only a single MAPI Notification Event can be bound to at a time. Calling the
EMBindEvent function releases the previous hook (if it exists) before instituting the new one. In the future
simultaneous hooks will be provided for.

Special thanks to Bo Durban for providing a workaround that made this method possible.

Function EMUnbindEvents()

Signature: EMUnbindEvents()

Parameters: None

Return Value:

Logical - indicating whether a hook that was created using EMBindEvent was removed - .T. for success and .F.
for failure

Remarks:

This function should be called after the EMBindEvent function when you wish to remove the hook. Issuing SET
LIBRARY TO also releases any active hook that may exist. Crashing or closing out of a system without removing
an active MAPI Notification Event hook can cause the user's email client to become unstable. It is strongly
recommended that a hook are removed as soon as you are through using it using EMUnbindEvents. Calling the
EMUnbindEvents function when no hook is active does not cause any problems or errors.

Das könnte Ihnen auch gefallen