MailConnect (Magic xpa 3.x)

« Go Back


Created ByKnowledge Migration User
Approval Process StatusPublished

MailConnect (Magic xpa 3.x)

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 do not know what it is, you can probably find it in your email software’s setup options.

The SMTP server is used to send mail. Some SMTP servers require a user name and password.

When this function is used to connect to a POP3 or an IMAP server, Magic xpa will connect to the user's mailbox on the server. For POP3 and IMAP servers, a user name and password are required.

When connected, the MailConnect function retrieves the new mails in the user's mailbox. New mail that the user receives after the connection has been made will not be available during that connection session but only after a new connection is made. Only one connection can be set to a send mail server and one connection to a receive mail server. If connected twice, the second connection overrides the first.


MailConnect(type, server, user, password)


Type: The server type; 1 = SMTP server, 2 = POP3 server, 3 = IMAP server

Server: string, address of mail server. This parameter supports the URL:Port format. This lets you define a port number that is not the mail server’s default port.

User, Password: string, user ID and password of the mailbox


When you try to connect to an SMTP mail server: a 0 return value means a successful connection, a negative value means a failed connection, and each negative value represents a specific error. A successful connection to a POP3/IMAP email server is indicated by 0 or a positive value, where each positive value represents the actual number of mails in the mailbox, and each negative value represents a specific error.


When you connect to a POP3 mail server, only the new messages are received. When you connect to an IMAP mail server, all existing messages, including both new and seen messages, are received.


This function does not use secure connections, so mail servers that require a secured connection, such as TLS or SSL, are not supported. For sending email using a TLS or SSL mail server, see: programs CN21 and RCN21.


For an SMTP server named, the connection string would be:

MailConnect (1,'','','')

See also:

Mail functions

Troubleshooting: Error -67 with Microsoft Exchange and the MailConnect function

The Online and Rich Client Samples projects (program EL01, EL02, REL01and REL02)