MMEmail

Dialog based email

Coding Considerations

Getting Results

Every time you use an MMEmail function, status text is returned back from the plug-in. This information can be very useful, for example, to let you know if an error occurred. Consider the following code:

MMEmail_SendMessage ( "someone@somedomain.com" ; "Hi!" ; "Just saying hi." )

The above code will send an email to someone@somedomain.com. If it is successful, the plug-in will return:

Email Sent Successfully.

However, if there was an error sending the email, the plug-in will return something like:

ERROR: SendMessage: SMTP Host is not defined. Please use MMEmail's Configuration Dialog to set an SMTP Host.

Curly Brackets

Curly brackets indicate that a parameter or parameters are optional. Take the MMEmail_Configure function for example:

MMEmail_Configure{( Option {; PrefName {; PrefValue }} )}

This function can be called without any parameters because the entire parameter section (what goes inside the parenthesis) is surrounded by curly brackets indicating that is it optional. Using the function in this manner looks like:

MMEmail_Configure

The above code simply opens the Configuration Dialog when called. However, you can use "Authentication" for the Option parameter to have the function open the Configuration Dialog to the "Authentication" tab:

MMEmail_Configure( "Authentication" )

Note that the above function is not defining the PrefName or PrefValue parameters. You can completely leave these off because they are also in Curly Brackets. Note that if there are optional parameters before one that you need to use, you must include any parameters before it. While it would not make sense for this function, if you were attempting to assign the PrefValue parameter without assigning the PrefName parameter, you would not be able to do this:

INCORRECT: MMEmail_Configure( "Set" ; "New Pref Value" )

You would need to specify the second parameter (PrefName) as well, even if you want to pass nothing (indicated by two double-quotes):

CORRECT: MMEmail_Configure( "Set" ; "" ; "New Pref Value" )

FileMaker Version Considerations

When plug-ins were first introduced, the only place you really wanted to use a plug-in function was the Set Field script step. However, since FileMaker 4, many new advancements have taken place. Though the Set Field script step is still a very common place to use plug-in functions, there are now many places that can logically be used. For a list of a few of these places, see the next section titled "Places to use MMEmail Functions".

It is important to keep in mind what versions of FileMaker will be in use when using MMEmail and other plug-ins. For example, creating a variable using the Set Variable script step can be very convenient, however, that functionality only exists in FileMaker 8 and greater. If you or your users use FileMaker 7, then your script calls would fall on deaf ears if you used Set Variable script step. In addition, when using functions in a variable you will be less likely to see the results returned from the plug-in (such as error messages), because a variable cannot but put on a layout like a field.

Places to use MMEmail Functions

You can use MMEmail functions in any calculation engine dialog in FileMaker. Keep in mind that just because you can do something does not mean it is actually useful.

There are several places that fit very well depending on the situation:

  • Calculation field
  • Auto-Enter Calculated value
  • Validation by calculation
  • Set Field Script/Button step
  • Insert Calculated Result Script/Button step
  • Show Custom Dialog
  • Set Variable Script/Button Step
  • Custom Functions
  • and more...