home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************
- HTBmail.dll
-
- Copyright 1999 TransEra Corporation
-
- htbmail.cpp
-
- With help from http://www.codeguru.com/internet/imapi.shtml
- *************************************************************/
-
- #include "stdafx.h"
- #include "HTBMAIL.h"
- #include <mapi.h>
- #include "imapi.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- BEGIN_MESSAGE_MAP(CHTBMAILApp, CWinApp)
- END_MESSAGE_MAP()
-
- CHTBMAILApp::CHTBMAILApp()
- {
- }
-
- CHTBMAILApp theApp;
-
- BOOL CHTBMAILApp::InitInstance()
- {
- return TRUE;
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- /*
- Function: Sendmailattach
-
- Description: Sends an e-mail message WITH an attatchment
-
- Return type: void
- Argument: char *MAddress
- Argument: char *MSubject
- Argument: char *MAttach
- Argument: char *MText
-
- Notes: This funtion will send an e-mail message with
- an attatchment. This is done through the
- MAPI interface which i wrapped in the
- IMapi.cpp file.
-
- */
- void Sendmailattach(char *MAddress, char *MSubject, char *MAttach, char *MText)
- {
- int err;
- int len = 0;
- char Delim[C_DELIM] = COMMA;
- char Addr[MAX_ADDR] = ADDR;
- char *pAddr = Addr;
-
- CIMapi mail;
-
- pAddr = strtok(MAddress, Delim);
-
- while (pAddr != NULL) // While loop for multiple recipients
- {
- mail.To(pAddr); // To
- pAddr = strtok(NULL, Delim);
- }
- mail.Subject(MSubject); // Subject
- len = strlen(MAttach); // Check length of path and filename
- err = SearchPath(NULL, MAttach, NULL, len, NULL, NULL); // Is the file really there?
- if (err > 0) // if it is, lets finish sending it
- {
- mail.Attach(MAttach); // Attaching a file
- mail.Text(MText); // Body
- mail.Send(); // Send it!
- }
- else // If it's not lets tell the user.
- {
- AfxMessageBox("Attachment Filename or Path incorrect:\nAborting Mail send!");
- } // Then we die.
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- /*
- Function: Sendmail
-
- Description: Sends Email message from HTBasic
-
- Return type: void
- Argument: char *MAddress
- Argument: char *MSubject
- Argument: char *MText
-
- Notes: This function will use the MAPI interface defined
- and wrapped in the IMapi class defined in IMapi.cpp.
- This sends a regular e-mai lmessage WITHOUT and attatchment.
-
- */
- void Sendmail(char *MAddress, char *MSubject, char *MText)
- {
- char Delim[C_DELIM] = COMMA; // Defined in HTBMAIL.h
- char Addr[MAX_ADDR] = ADDR; // Defined in HTBMAIL.h
- char *pAddr = Addr;
-
- CIMapi mail;
- pAddr = strtok(MAddress, Delim);
-
- while (pAddr != NULL) // While loop for multiple recipients
- {
- mail.To(pAddr); // To
- pAddr = strtok(NULL, Delim);
- }
- mail.Subject(MSubject); // Subject
- mail.Text(MText); // Body
- mail.Send(); // Send it!
- }