README.TXT Notes for Custom Message Class Example Version 0.1 (C) Copyright DATAVIZ, 1994 ------------------------ How to Use This Document ------------------------ To view README.TXT on screen in Windows Notepad, maximize the Notepad window. To print README.TXT, open it in Windows Write, Microsoft Word, or another word processor. Then select the entire document and format the text in 10-point Courier before printing. ======== Contents ======== Part Description ---- ----------- 1 Copyright and Company Development Information 2 Software Installation and Custom Message Installation 3 Functionality 4 "Custom Message Sender" Source Code 5 "Custom Message Catcher" Source Code ============================================================== Part 1: Copyright Information ============================================================== Custom Message Class Example, Copyright (c) 1994 DATAVIZ® This program may be distributed freely on the condition that it is distributed in full, and unmodified, and that no fee is charged for such distribution with the exception of reasonable media and shipping charges. Any or all portions of the source code may be incorporated into your own programs, and those programs may be distributed without payment of royalties on the condition that such programs differ substantially from this example program. The custom message class IPM.DATAVIZ.Intercept is copyrighted and many not appear in any way in other applications. Thank you for your cooperation. DATAVIZ® "Designing Visual Solutions for Data" (206)328-1523 72603.1674@Compuserve.com dataviz000@aol.com ============================================================== Part 2: Software Installation and Custom Message Installation ============================================================== To install "Custom Message Sender" and "Custom Message Catcher", use the Program Manager or File Manager to start SETUP.EXE as you would any other Windows-based application. For example, if you are installing from drive A: - From the Program Manager File menu, choose Run. - In the Run dialog box, type A:SETUP and choose OK. Or - From the File Manager, double-click the SETUP.EXE file icon on drive A. Notes: - The setup program will make a modification to your MSMAIL.INI file in the custom message section. It will add this line, refers to the location of the files when installed. This will automatically be updated in the MSMAIL.INI file. IPM.DATAVIZ.Intercept=3.0;;;;\APPEXEC.DLL;\CATCHER.EXE;1111111100000000;;;; - For a detailed description of exactly what a custom message is for MS Mail I recommend ordering the "Microsoft Mail Technical Reference Manual." This gives a detailed explanation of exactly what each section of the custom message is located on pages 23-42. ====================== Part 3: Functionality ====================== These 2 applications where written to show how to use the custom message feature of MS Mail. You can use the custom message to intercept any known message class coming into your in-basket of MS Mail. This can be used to do automated emails back to a paticular person or group that you get mail from and that has a custom message class. As mentioned above the "Microsoft Mail Technical Reference Manual" is an excellent manual for learning what parameters are what and how to use these messages from C\C++ or VB. The "Custom Message Sender" application creates a mail message with a custom message type of IPM.DATAVIZ.Intercept but using the MSMAPI.VBX control, and then send it away to the specified person. The "Custom Message Catcher" application is executed when that paticular custom message comes into your mailbox, this is done by using the APPEXEC.DLL, an example DLL, this uses a parameterblock to send info to another application or to execute a specified application. You will notice that the "Custom Message Catcher" works in 2 ways, as soon as the custom message class comes into the inbox it fires off the catcher, also when you double click on the message in the inbox it will fire off the "Custom Message Catcher." ============================================ Part 4: "Custom Message Sender" Source Code ============================================ - Form (general) '--------------------------------------- ' MAPI SESSION CONTROL CONSTANTS '--------------------------------------- 'Action Const SESSION_SIGNON = 1 Const SESSION_SIGNOFF = 2 '--------------------------------------- ' MAPI MESSAGE CONTROL CONSTANTS '--------------------------------------- 'Action Const MESSAGE_FETCH = 1 ' Load all messages from message store Const MESSAGE_SENDDLG = 2 ' Send mail bring up default mapi dialog Const MESSAGE_SEND = 3 ' Send mail without default mapi dialog Const MESSAGE_SAVEMSG = 4 ' Save message in the compose buffer Const MESSAGE_COPY = 5 ' Copy current message to compose buffer Const MESSAGE_COMPOSE = 6 ' Initialize compose buffer (previous ' data is lost Const MESSAGE_REPLY = 7 ' Fill Compose buffer as REPLY Const MESSAGE_REPLYALL = 8 ' Fill Compose buffer as REPLY ALL Const MESSAGE_FORWARD = 9 ' Fill Compose buffer as FORWARD Const MESSAGE_DELETE = 10 ' Delete current message Const MESSAGE_SHOWADBOOK = 11 ' Show Address book Const MESSAGE_SHOWDETAILS = 12 ' Show details of the current recipient Const MESSAGE_RESOLVENAME = 13 ' Resolve the display name of the recipient Const RECIPIENT_DELETE = 14 ' Fill Compose buffer as FORWARD Const ATTACHMENT_DELETE = 15 ' Delete current message '--------------------------------------- ' ERROR CONSTANT DECLARATIONS (MAPI CONTROLS) '--------------------------------------- Const SUCCESS_SUCCESS = 32000 Const MAPI_USER_ABORT = 32001 Const MAPI_E_FAILURE = 32002 Const MAPI_E_LOGIN_FAILURE = 32003 Const MAPI_E_DISK_FULL = 32004 Const MAPI_E_INSUFFICIENT_MEMORY = 32005 Const MAPI_E_ACCESS_DENIED = 32006 Const MAPI_E_TOO_MANY_SESSIONS = 32008 Const MAPI_E_TOO_MANY_FILES = 32009 Const MAPI_E_TOO_MANY_RECIPIENTS = 32010 Const MAPI_E_ATTACHMENT_NOT_FOUND = 32011 Const MAPI_E_ATTACHMENT_OPEN_FAILURE = 32012 Const MAPI_E_ATTACHMENT_WRITE_FAILURE = 32013 Const MAPI_E_UNKNOWN_RECIPIENT = 32014 Const MAPI_E_BAD_RECIPTYPE = 32015 Const MAPI_E_NO_MESSAGES = 32016 Const MAPI_E_INVALID_MESSAGE = 32017 Const MAPI_E_TEXT_TOO_LARGE = 32018 Const MAPI_E_INVALID_SESSION = 32019 Const MAPI_E_TYPE_NOT_SUPPORTED = 32020 Const MAPI_E_AMBIGUOUS_RECIPIENT = 32021 Const MAPI_E_MESSAGE_IN_USE = 32022 Const MAPI_E_NETWORK_FAILURE = 32023 Const MAPI_E_INVALID_EDITFIELDS = 32024 Const MAPI_E_INVALID_RECIPS = 32025 Const MAPI_E_NOT_SUPPORTED = 32026 Const CONTROL_E_SESSION_EXISTS = 32050 Const CONTROL_E_INVALID_BUFFER = 32051 Const CONTROL_E_INVALID_READ_BUFFER_ACTION = 32052 Const CONTROL_E_NO_SESSION = 32053 Const CONTROL_E_INVALID_RECIPIENT = 32054 Const CONTROL_E_INVALID_COMPOSE_BUFFER_ACTION = 32055 Const CONTROL_E_FAILURE = 32056 Const CONTROL_E_NO_RECIPIENTS = 32057 Const CONTROL_E_NO_ATTACHMENTS = 32058 '--------------------------------------- ' MISCELLANEOUS CONSTANT DECLARATIONS (MAPI CONTROLS) '--------------------------------------- Const RECIPTYPE_ORIG = 0 Const RECIPTYPE_TO = 1 Const RECIPTYPE_CC = 2 Const RECIPTYPE_BCC = 3 Const ATTACHTYPE_DATA = 0 Const ATTACHTYPE_EOLE = 1 Const ATTACHTYPE_SOLE = 2 '--------------------------------------- ' MESSAGEBOX PARAMETERS '--------------------------------------- Const MB_OK = 0 ' OK button only Const MB_OKCANCEL = 1 ' OK and Cancel buttons Const MB_ABORTRETRYIGNORE = 2 ' Abort, Retry, and Ignore buttons Const MB_YESNOCANCEL = 3 ' Yes, No, and Cancel buttons Const MB_YESNO = 4 ' Yes and No buttons Const MB_RETRYCANCEL = 5 ' Retry and Cancel buttons Const MB_ICONSTOP = 16 ' Critical message Const MB_ICONQUESTION = 32 ' Warning query Const MB_ICONEXCLAMATION = 48 ' Warning message Const MB_ICONINFORMATION = 64 ' Information message Const MB_APPLMODAL = 0 ' Application Modal Message Box Const MB_DEFBUTTON1 = 0 ' First button is default Const MB_DEFBUTTON2 = 256 ' Second button is default Const MB_DEFBUTTON3 = 512 ' Third button is default Const MB_SYSTEMMODAL = 4096 'System Modal - Form code Sub Form_Load () ' Set the application title for the task manager. App.Title = "Custom Message Sender" End Sub - Command button code Sub cmd3dMail_Click (Index As Integer) ' Error trapping. On Error GoTo MAPIERR: Select Case Index Case 0 ' Logon. ' Make sure either the person is logged onto mail and ' use that session or create a new session and log ' the user on with the appropriate dialog box. MapiSession1.Action = SESSION_SIGNON ' Set the message and session ids equal. MapiMessages1.SessionID = MapiSession1.SessionID Case 1 ' Send Class ' Set the message index to -1 for compose buffer ' reasons. MapiMessages1.MsgIndex = -1 ' Setup the subject line of the message. MapiMessages1.MsgSubject = "Custom Message Interception Test" ' This is were I am sending to MS Mail the NEW ' custom message class, and this is what will be read ' in the inbox when the message is opened. MapiMessages1.MsgType = "IPM.DATAVIZ.Intercept" ' Setup the text of the message. MapiMessages1.MsgNoteText = "Visual Basic 3.0 Custom Message Interception Test." ' This will bring up the dialog box of the compose ' screen, I did this so that you could enter in an email ' name to send to instead fo hardcoding it. MapiMessages1.Action = MESSAGE_SENDDLG Case 2 ' Logoff ' This will sever the session with MS Mail. MapiSession1.Action = SESSION_SIGNOFF End Select Exit Sub: MAPIERR: ' Simple display dialog that shows error string and number. MsgBox Error$ & " (#" & Err & ")", MB_ICONSTOP, App.Title Resume Next End Sub - Menu Code Sub mnuIdx_Click (Index As Integer) Select Case Index Case 0 'About. Dim sMsg As String sMsg = "Custom Message Class Sender" & Chr(13) & Chr(10) & Chr(13) & Chr(10) sMsg = sMsg & "This will send a cutom message class, IPM.DATAVIZ.Intercept, " sMsg = sMsg & "to MS Mail by using the MSMAPI.VBX controls. It creates the " sMsg = sMsg & "note to send all you have to do is type in an email name to " sMsg = sMsg & "send it to. Also it is important that you have the 'Custom " sMsg = sMsg & "Message Catcher' installed on your drive and that you have the " sMsg = sMsg & "custom message class registered in your MS Mail Intialization file." & Chr(13) & Chr(10) & Chr(13) & Chr(10) sMsg = sMsg & "For questions/suggestions or contract work call:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) sMsg = sMsg & "DATAVIZ®" & Chr(13) & Chr(10) sMsg = sMsg & "'Designing Viusal Solutions for Data'" & Chr(13) & Chr(10) & Chr(13) & Chr(10) sMsg = sMsg & "(206) 328-1523" & Chr(13) & Chr(10) sMsg = sMsg & "76203.1674@compuserve.com" & Chr(13) & Chr(10) sMsg = sMsg & "dataviz000@aol.com" & Chr(13) & Chr(10) MsgBox sMsg, , App.Title Case 2 ' Exit. ' This will sever the session with MS Mail, ensures ' that the person logs off this session properly. MapiSession1.Action = SESSION_SIGNOFF ' This will terminate the application. End End Select End Sub ============================================= Part 5: "Custom Message Catcher" Source Code ============================================= - Form Code (general) Option Explicit '------------------------------------------- ' Constants for the SetWindowPos API Call. '------------------------------------------- Const SWP_NOMOVE = 2 Const SWP_NOSIZE = 1 Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE '------------------------------------------- ' Windows 3.1 API Function Declaration '------------------------------------------- Declare Function SetWindowPos Lib "User" (ByVal hWnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, >> >>ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer - Form Code Sub Form_Load () ' Set the application title for the task manager. App.Title = "Custom Message Catcher" Dim iRC As Integer ' Position the form to be topmost as all other forms load, this ' form is used in relation to those of Word 6.0 and Excel 5.0. iRC = SetWindowPos(Me.hWnd, -1, 0, 0, 0, 0, FLAGS) End Sub - Command button code Sub cmdOK_Click () ' This will terminate the application. End End Sub