How to send an Email ? |
IntroductionYou can send emails within Magic in two ways : without user intervention (by using a DLL, a command line program or OLE Automation) or with user intervention (invoke the email application, and specify the recipient, the subject, ...). Magic eDeveloper V9 now supports POP3, SMTP and IMAP protocols to read and send email, implemented as a set of nice integrated functions. It is a good practice to purpose several ways to send an email in your application, as the best solution often depends on user architecture. MAPI, Simple MAPI or CMCThis mailer tools use the installed mail package to send an email. If simple MAPI is provided with most mail applications, MAPI (that provides a larger set of functions) is mostly provided by Exchange or Outlook. MAPI is Windows specific, but CMC can be implemented on several systems (Unix, Windows), although CMC is no more implemented in Outlook. By MAPI design, you can't use MAPI from a service. Outlook and Outlook Express are often used by computer viruses to propagate. Microsoft has put several limits on recent versions, so those versions are no more really compatible simple MAPI (limits on attachments, dialog boxes for user confirmation, ...). Take this in consideration if you choose this way to send mails. The advantages of MAPI are
The disadvantages of MAPI are
MAPI is the standard method to send an email in Windows, so it's used in several solutions.
SMTPThis protocol is the standard internet mail protocol to send emails, all ISP provides it and most Mail Servers have an option to accept it (including Exchange Server). As this tools does not use the installed mail package, they are quicker and self-contained, but require more configuration (smtp server address, login, password).
VIM (Lotus Notes)
OLE AutomationFor Magic 8.20 or upper, OLE automation commands depends on the email package. If you can download Email from Magic from magicu-l shared folder, that uses OLE Automation to Outlook. Mems Software sells a Magic DLL for Magic V7 or upper MagicToOutlook (mgoutlk.dll) that interfaces with Outlook through OLE. SQL gatewayMicrosoft SQL Server or MSDEThe KBase article Q263556 explains how to send mail from SQL. (Also look at KB 321183, KB 311231, KB 315886) Invoking Email PackageMailto: ProtocolYou can use the exit Magic operation : mailto:address[,address]?subject=subject line&cc=address[,address]&bcc=address[,address]&body=message text&attachment='one file'. Be aware that the whole command (including body text) must fit into the command line system limit (under 500 bytes under Windows 95). The first separator is ?, following are &. You must use hexadecimal characters for special characters in variables, the following signs are used to represent commonly used characters:
You can use 'hotfudge.mailto' or 'mailget.mailto' that deals with the conversion, if you want to do things yourself, be aware that Magic will alter the string, as '%' are interpreted as logical names, so you have to create a batch file (.bat) and launch this batch program through the 'exit' operation. All mail packages does not support all the switches, although address and subject are commons, and attachment is quite rare. The RFC 2368 describes this protocol. The user still have to use the send button. AttachmentsTo send reports via attachment, you have to make this reports in a format that the recipient can read :
Another solution is to use a report generator or to produce a report in an intermediary format that can generate PDF :
|