|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionDuring the software development, I have seen many applications that requires incorporating email support. I remember, once I was to develop an application, which sends emails at the specific time to specific people with the customized messages. For that I developed a COM service that used MAPI. MAPI, i.e. Messaging Application Programming Interface, is the standard messaging architecture and a complete set of functions and object-oriented interfaces. Here I have an Email component, a COM DLL, which is a set of messaging functions that helps you create messaging-enabled applications. This COM component uses Simple MAPI to achieve that. Note: MAPI is used by various industry-standard e-mail clients, such as the Microsoft Exchange client, all versions of Microsoft Outlook and Outlook Express, including QUALCOMM Incorporated (Eudora) and Netscape Communications Corporation. So you can use this component with these client applications also. Component DesignThe
Steps to execute the demo projectThe demo project demonstrates the way you can use the component to send an email. In order to execute the demo project, the following settings are required: Step 1: You must have some valid Output Express email account or create one named TestProfile.You can create an email profile in Express from Tools>Accounts menu. This will open Internet Accounts property sheet. On the tab All, click the button Add and then Mail. A wizard will let you create an email account, specify the valid email address. For hotmail account, wizard automatically sets the names of email servers.
After successfully creating the account, select the account name from the list in All tab (for hotmail account, the default account name is Hotmail). Open account properties by pressing Properties button and change the account name from default name (say Hotmail) to TestProfile.
Step 2: Register the DLLAll COM DLLs required to be registered. After copying the DLL source code, you can register the DLL by right clicking the DLL and selecting Register DLL or Register COM component option, or simply by double clicking the DLL. Compiling the DLL code in Visual Studio will automatically register the DLL. Step 3: Logged on to the netMake sure you are logged on to the net. If not, outlook will fail to deliver the email, however, you can still check the composed email in your outbox. How to send email?After specifying the information in the dialog box, click the Send button. A warning message will be displayed, click Send button.
Note:The warning dialog is displayed because of the security constraints. If you want to get rid of this dialog box, then you will have to use Extended MAPI instead of simple MAPI.
Here is the method //##//##////////////////////////////////////////////////////////////// /////////////////////////////////////////////// // // void CTestEmailDlg::OnSend() // // This module is called when send button is pressed and uses //Email COM DLL to send email - Aisha Ikram // Note: dont forget to initialize COM library using CoInitialize(NULL); //##//##//////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// void CTestEmailDlg::OnSend() { UpdateData(); try{ CComPtr Check the mail in the recipient inbox.
Where to useThis component can be extended to incorporate the functionalities like opening an existing inbox to read emails automatically from the inbox and composing new emails etc. It can be used to send emails automatically with customized user messages and attachments to specific people at particular time, especially while using some exe servers or NT services. That's it. If there is any suggestions or comments you are most welcome. Your rating would help me evaluate the standard of my article. Looking for a Class instead of a COM component?I have also build a class You can find all at my website (free code and articles website).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||