writing email wrapper method

I’m attempting to write a global method that will serve as a general method (a wrapper) to send emails via our solution.

I’m pretty new to writing methods, so I thought that I would start this topic to track my progress as well give me a place to ask for help. :)

I’m planning on using the Mail plugin.

Here’s what we need:

  1. We want the method to open a new message for editing in the default email client on the user’s computer.

I’ve already found this HOWTO, but haven’t tried it yet:
http://forum.servoy.com/viewtopic.php?p=3110#3110

  1. The email, once opened in the user’s email client and ready for editing, will be prepopulated with some or all of the pertinent information that will be sent in the email. This may include any or all of the following:
    from_address
    to_address(es)
    cc_address(es)
    bcc_address(es)
    subject
    message text (can be html formatted if it starts with the tag)
    attachment(s)

Here’s what I’ve done so far:

  1. Created a new global method, sendEmail

  2. Briefly declared my variables:

var to_address = new Array();
var from_address; 
var subject;
var msgText; //can be html if you start with an <html> tag.
var cc_address = new Array();
var bcc_address = new Array();
var attachments = new Array();
  1. Moved over sample code from the sendMail method of the Mail plugin.

My first question is about the format of the method. I would like to make it so that when people think about using this method, they can quickly see what properties need to be declared, and in what order (order matters, right?).

My second question is about the arrays. If more than one to_address is the array, how do I pass this to Mail’s sendMail method?

Thanks for any help, comments, or suggestions.

I’m a bit confused in that you are using the Mail plugin, but also wanting to send through the user’s default mail client. The Mail Plugin will allow you to send through Servoy, without the user’s mail Client.

For your first question, we use this in the beginning of most methods that are used in Modules (aka, called alot)

/******************************************
SB 5/9/06

Description of method...blah blah blab

Parameters:
[0] - paramName (paramType) (not if not required)

Returns:
description of what it returns
******************************************/

Unfortunatly, in Servoy, there is no other way to note what parameters are takin and returned with Serovy Methods, that can only be done with Plugins.

If you are interested, I have included a module that we wrote and use for our email needs insider of Servoy. It has a GUI for the user to edit the message, headers and add add attachments. It hase methods for a GUI for, or to send a message transparently. It also stores the emails sent in a Log table for historical reference, and has a GUI to view the log…but maybe it will help you get started.

After including the module in your solution, an example call to show the GUI would look like this

globals.mod_email_sendMessageFormInDialog('me@servoy.com',null,null,null,null,'some customer id');