|
void MySendMail2( HWND hWnd );
// バージョン情報ボックス用メッセージ ハンドラ
LRESULT CALLBACK About( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message ) {
case WM_INITDIALOG:
SetFocus( GetDlgItem( hDlg, IDC_TO ) );
return FALSE;
case WM_COMMAND:
if( LOWORD(wParam) == IDOK ) {
if ( MessageBox(
hDlg,
"メールを送信しますか?",
"確認",
MB_OKCANCEL
) == IDOK ) {
MySendMail2( hDlg );
}
return TRUE;
}
if( LOWORD(wParam) == IDCANCEL ) {
EndDialog( hDlg, LOWORD(wParam) );
return TRUE;
}
break;
}
return FALSE;
}
typedef int (* LPSendMail)
(
LPCSTR szServer,
LPCSTR szTo,
LPCSTR szFrom,
LPCSTR szSubject,
LPCSTR szBody,
LPCSTR szFile,
LPSTR msg
);
void MySendMail2( HWND hWnd )
{
int ret;
char *pszSmtpServer = "localhost";
char szTo[80];
char szFrom[80];
char szSubject[80];
char szBody[4096];
char szErrorMessage[80];
szErrorMessage[0] = 0x00;
GetDlgItemText( hWnd, IDC_TO, szTo, 80 );
GetDlgItemText( hWnd, IDC_FROM, szFrom, 80 );
GetDlgItemText( hWnd, IDC_SUBJECT, szSubject, 80 );
GetDlgItemText( hWnd, IDC_BODY, szBody, 4096 );
HINSTANCE DllLib;
LPSendMail BSMTP_BSendMail;
DllLib = LoadLibrary( "BSMTP.DLL" );
if ( DllLib == NULL ) {
MessageBox(
hWnd,
"BSMTP.DLL のロードに失敗しました",
"確認",
MB_OK
);
return;
}
BSMTP_BSendMail = (LPSendMail)GetProcAddress( DllLib, "BSendMail" );
if ( BSMTP_BSendMail == NULL ) {
FreeLibrary( DllLib );
MessageBox(
hWnd,
"BSendMail のアドレスの取得に失敗しました",
"確認",
MB_OK
);
return;
}
ret = BSMTP_BSendMail(
pszSmtpServer,
szTo,
szFrom,
szSubject,
szBody,
NULL,
szErrorMessage
);
FreeLibrary( DllLib );
if ( szErrorMessage[0] != 0x00 ) {
MessageBox( hWnd, szErrorMessage, "エラーメッセージ", MB_OK );
}
}
| |