# Saturday, June 09, 2007
Due to a deafening roar of requests that the vfpexmap.fll support HTML, I have created an update that includes an additional function called EMCreateMessageEx (not to be confused with the EMCreateMessage function used to send plain text). This new function provides the ability to send HTML and RTF emails. I've updated my previous blog entry that contains the complete documentation and example code. Here's a link to the new FLL (all other links to vfpexmapi.zip on this blog also point to this updated file, so no need to worry about where you get it from here), an example of use in VFP, and the documentation for the new function...

Download Visual FoxPro Extended MAPI FLL (size 10 KB approx.)


#define MAPI_ORIG 0
#define MAPI_TO 1
#define MAPI_CC 2
#define MAPI_BCC 3
#define IMPORTANCE_LOW 0
#define IMPORTANCE_NORMAL 1
#define IMPORTANCE_HIGH 2
CLEAR
LOCAL lcHTML, lcRTF
SET LIBRARY TO LOCFILE("vfpexmapi.fll")
*****************************
*!* Send HTML Email
*****************************
TEXT TO m.lcHTML NOSHOW
<html>
<body>
<p>Here's an HTML email.</p>
<ul>
<li>The</li>
<li><a href="http://www.sweetpotatosoftware.com/SPSBlog/">SPS Weblog</a></li>
<li>is Back.</li>
</ul>
<p>Visual FoxPro Rocks!</p>
</body>
</html>
ENDTEXT
?
?"Sending HTML Email"
?EMCreateMessageEx("HTML Test", m.lcHTML, IMPORTANCE_HIGH)
?EMAddRecipient("someone@somedomain.com", MAPI_TO)
?EMSend()
*****************************
*!* Send RTF Email
*****************************
TEXT TO m.lcRTF NOSHOW
{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard
Here is a {\b Rich Text Format} email.\par
}
ENDTEXT
?
?"Sending RTF Email"
?EMCreateMessageEx("RTF Test", m.lcRTF, IMPORTANCE_LOW)
?EMAddRecipient("someone@somedomain.com", MAPI_TO)
?EMSend()


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.


Saturday, June 09, 2007 3:48:07 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0]
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<August 2010>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234