SWEmail.DLL - SmartWare email routines - v3.0.1.0 - 6 February 2008 ******************************************************************* This DLL provides MAPI, SMTP & POP3 email functionality in a way that can be easily called from SmartWare. Documentation is provided in a separate file. Licence: ******** The DLL and associated SmartWare code may be used free of charge, unless permission has been explicitly denied by Neil Parrish or I O Systech Ltd. However the source code & DLL may not be distributed or used as part of a competitive product. Any variations of the product produced from the source code require licences for distribution to external clients. Version Notes: ************** 3.0.1.0 - 6 February 2008 Added clear to POP3NextMessage to stop an issue with the subject not being reset and showing when a second message is forwarded Removed a redundant RetrieveRaw from POP3Forward 3.0.0.0 - 31 January 2008 Added SMTP & POP3Collection routines MAPI routine renamed MAPISend and error return value changed to -1 2.0.0.0 - 20 January 2007 Recompiled with Delphi 6, necessitating cast of PChar MailFile to string Added handling of all files in a folder via a *.* attachment Added comments, version info and setting of image base address Contact Details: **************** Produced By: I O Systech Limited Author: Neil Parrish Website: www.iosystech.co.uk Email: enquiries@iosystech.co.uk Phone: +44 (0)7041 420182 Fax: +44 (0)8707 064666 +44 (0)1784 432058 Function Documentation ********************** MAPISend -------- Generates an email in a MAPI compliant email client. Parameters: MailFile Full path & name of the text file specifying the email ProfileName Profile to be used by the messaging API Password Password to be used during logon Review Controls whether compose message dialog is displayed True-displayed False-only displayed if incomplete Mailfile Specification: The text file specified by MailFile uses ^! and a letter on a control line to identify the purpose of the following lines. Any further text on the control line is ignored so ^!S or ^!Subject can both be used to specify the following line is the subject. Valid control sequences are; ^!T direct recipient(s) of the message, one per line ^!C carbon copy recipient(s) of the message, one per line ^!B blind carbon copy recipient(s) of the message, one per line ^!S subject of the message, a single line should follow ^!M contents of the message ^!A files to be attached to the message, one per line, *.* may be used to specify all the files in the folder A simple email text file may look like this; ^!T <--- could be ^!To enquiries@iosystech.co.uk ^!S <--- could be ^!Subject Sample SWMEmail email ^!M <--- could be ^!Message This is the simplest possible test SWEmail email Return Values: (See note below) The DLL call will return 1 if successful and -1 in the event of failure POP3Close --------- Disconnects from the POP3 mailbox connected to by POP3Open. Parameters: None Return Values: (See note below) The DLL call will return 1 if successful and -1 in the event of failure POP3Delete ---------- Deletes the current message in the POP3 mailbox. Parameters: None Return Values: (See note below) The DLL call will return 1 if successful and -1 in the event of failure POP3Forward ----------- Forwards the current message in the POP3 mailbox and then deletes it. Parameters: fwSubjText Text to be added at the beginning of the subject fwTo Address of the recipient fwFromAdd Address of the sender fwFromName Name of the sender fwText Text to be added at the beginning of the email Return Values: (See note below) The DLL call will return 1 if successful and -1 in the event of failure POP3NextMessage --------------- Retrieves the next message from the POP3 mailbox into a file. Parameters: msgFileName name of the file to save the email message in Return Values: (See note below) The DLL call will return 1 if successful, 0 if there are no more messages and -1 in the event of failure POP3Open -------- Opens the POP3 mailbox and reports the number of messages Parameters: PHost POP3 mailbox server PUserID POP3 server account user id PPassword POP3 server account password SHost SMTP server to forward messages via SUserID SMTP server account user id SPassword SMTP server account password PPort Port number for POP3 server (usually 110) SPort Port number for SMTP server (usually 25) Return Values: (See note below) The DLL call will return the number of messages in the mailbox if successful and -1 in the event of failure SMTPQuickSend ------------- Generates a simple SMTP message, suitable for SMTP servers that do not authenticate on connection. Parameters: Host SMTP server to send the mail via Subject Subject line for the email SendTo Address of the recipient From Address of the sender MessageText Text of the email message Return Values: (See note below) The DLL call will return 1 if successful and -1 in the event of failure SMTPSend -------- Sends an email via an SMTP server Parameters: MailFile Full path & name of the text file specifying the email SHost SMTP server to send messages via SUserID SMTP server account user id SPassword SMTP server account password SPort Port number for SMTP server (usually 25) Mailfile Specification: The text file specified by MailFile uses ^! and a letter on a control line to identify the purpose of the following lines. Any further text on the control line is ignored so ^!S or ^!Subject can both be used to specify the following line is the subject. Valid control sequences are; ^!T direct recipient(s) of the message, one per line ^!C carbon copy recipient(s) of the message, one per line ^!B blind carbon copy recipient(s) of the message, one per line ^!F senders name and/or address (detected by @), one per line ^!R reply to address ^!S subject of the message, a single line should follow ^!M contents of the message ^!A files to be attached to the message, one per line, *.* may be used to specify all the files in the folder A simple email text file may look like this; ^!T <--- could be ^!To enquiries@iosystech.co.uk ^!S <--- could be ^!Subject Sample SWMEmail email ^!M <--- could be ^!Message This is the simplest possible test SWEmail email Return Values: (See note below) The DLL call will return 1 if successful and -1 in the event of failure Return Values ************* The GETRG(AX) function in SmartWare does not return negative numbers correctly. To check the return values of the DLL use a function like this: FUNCTION _intAX() LOCAL #AXReg #AXreg = GETREG(AX) IF BITAND(#AXreg,0x80000000) 'negative value #AXreg = (#AXreg - 0x80000000) - 0x80000000 END IF RETURN #AXreg END FUNCTION *****************************************************************************