Salesforce

How Do I Send an Email? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Send an Email? (Magic xpa 3.x)

Magic xpa has some built-in email functions to send and receive email.

To send an email, there are two steps:

  1. Connecting to the server, and

  2. Sending the mail

We’ll cover these individually.

Connecting to the server

You connect to the server using the MailConnect() function. In order to do this, you need to know the name of your mail server. If you don’t know what that is, you can probably find it in your email software’s setup options. The MailConnect() syntax is:

MailConnect (type, server, user, password)

where:

  • Type stands for the server type. 1=SMTP, 2=POP3, 3=IMAP

  • Server is the address of the server

  • Userid is the user’s ID

  • Password is the user’s password

For an SMTP server named juno.olympus.com, the connection string would be:

MailConnect (1,'juno.olympus.com','','')

The return code depends on what kind of server you are connecting to. You can get the details in the MailConnect help entry.

Sending the email

Once you are connected to the server, you can send the mail using the MailSend() function. The syntax of that function is:

MailSend (From, To, Cc, Bcc, Subject, Message, Attachment)

Where:

From is the From email address. This is not checked, so it can basically be anything.

To is the To email address. If this is incorrect, the mail will not arrive.

Cc is a list of email address to Cc.

Bcc is a list of email address to Bcc.

Subject is the text that shows on the subject line.

Message is the text of the message itself.

Attachment is a string representing a file to send as an attachment.

So one example might be:

MailSend ('jenny@frigates.com', 'fred@aaawidgets.com', '', '', 'May Invoice', 'Attached is your May invoice', 'F:\Invoices\aaa_11_2007.pdf')

Of course, you will probably use variables, not hard-coded text. This is a very straightforward syntax. You can string multiple addresses together, separated by commas. You can also string together multiple attachments.

The return code is numeric, where zero means success. If the return code is not zero, you can use the return code as a parameter to the MailError() function to show a user-friendly error message. If the return code is in the variable BP, then

'Send return code: '&Str (BP,'5NC')&' '&MailError (BP)

will give a structured message with the error code number and message.

See also

The Online and Rich Client Samples projects (program EL01 and REL01)

Reference
Attachment 
Attachment