LboxBasp

  コンストラクタ



Basp21 をインストールする必要があります

このクラスを使用する場合は、アプリケーションの開始処理に CoInitialize( NULL ) を実行し、
アプリケーションの終了処理に CoUninitialize( ) を実行して下さい

  
// *********************************************************
// デフォルトコンストラクタ
// *********************************************************
LboxBasp::LboxBasp()
{
	this->lib = LoadLibrary( "Bsmtp.dll" );

	User.SetChar( 0, 0 );
	Password.SetChar( 0, 0 );

	LboxTool Tool;
	LboxFileSystem Fs;

	RcvDir.Resize( MAX_PATH );
	Tool.ProgramDirectory( this->RcvDir.szLboxString );
	this->RcvDir.AddBackslash();
	this->RcvDir.operator += ( "RcvDir" );
	if ( !(Fs.IsDirectory( this->RcvDir.szLboxString ) ) ) {
		Fs.CreateDirectory( this->RcvDir.szLboxString );
	}

}

// *********************************************************
// デストラクタ
// *********************************************************
LboxBasp::~LboxBasp()
{
	if ( this->lib != NULL ) {
		FreeLibrary( this->lib );
	}
}
  



  SendMail



  
// *********************************************************
// メール送信
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::SendMail(
	LboxString *LTo, LboxString *LFrom, LboxString *LSubj, LboxString *LBody )
{
	return LboxBasp::SendMail(
		LTo->szLboxString,
		LFrom->szLboxString,
		LSubj->szLboxString,
		LBody->szLboxString
	);
}
BOOL LboxBasp::SendMail(
	LPTSTR lpTo, LPTSTR lpFrom, LPTSTR lpSubject, LPTSTR lpBody )
{
	this->ErrorDescription.SetChar(0,0);

	if ( this->lib == NULL ) {
		this->ErrorDescription.operator = (
			"Bsmtp.dll がインストールされていません"
		);
		return false;
	}

	LPFUNC_BSendMail DllBSendMail;

	DllBSendMail =
		(LPFUNC_BSendMail)GetProcAddress( lib, "BSendMail" );
	if ( DllBSendMail == NULL ) {
		return false;
	}

	int nRet;

	this->ErrorDescription.SetChar( 0, 0 );
	nRet = DllBSendMail(
		this->SMTPServer.szLboxString,
		lpTo,
		lpFrom,
		lpSubject,
		lpBody,
		"",
		this->ErrorDescription.szLboxString
	);

	if ( !nRet ) {
		return false;
	}

	return true;

}
  



  RcvList

  
// *********************************************************
// メールヘッダ情報受信
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::RcvList( LboxListview *Lview )
{
	if ( this->User.operator == ( "" ) ) {
		return false;
	}
	return LboxBasp::RcvList(
		this->User.szLboxString,
		this->Password.szLboxString,
		Lview
	);
}
BOOL LboxBasp::RcvList(
	LboxString *LUser, LboxString *LPass, LboxListview *Lview )
{
	return LboxBasp::RcvList(
		LUser->szLboxString,
		LPass->szLboxString,
		Lview
	);
}
BOOL LboxBasp::RcvList(
	LPTSTR lpUser, LPTSTR lpPass, LboxListview *Lview )
{
	this->ErrorDescription.SetChar(0,0);

	if ( this->lib == NULL ) {
		this->ErrorDescription.operator = (
			"Bsmtp.dll がインストールされていません"
		);
		return false;
	}

	LPFUNC_BPOP3 DllBPOP3;
	LPFUNC_BFreeArray DllBFreeArray;

	DllBPOP3 =
		(LPFUNC_BPOP3)GetProcAddress( lib, "BPOP3" );
	if ( DllBPOP3 == NULL ) {
		return false;
	}
	DllBFreeArray =
		(LPFUNC_BFreeArray)GetProcAddress( lib, "BFreeArray" );
	if ( DllBFreeArray == NULL ) {
		return false;
	}


	int nRet;
	RetArray ra;

	this->ErrorDescription.SetChar( 0, 0 );
	nRet = DllBPOP3(
		this->POP3Server.szLboxString,
		lpUser,
		lpPass,
		"LIST",
		this->RcvDir.szLboxString,
		&ra,
		this->ErrorDescription.szLboxString
	);

	if ( nRet <= 0 ) {
		return false;
	}

	Lview->Initialize();
	Lview->AddColumn( LVCFMT_LEFT, 100, "" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "送信者" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "件名" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "受信日時" );

	int i;
	LboxToken Ltoken;
	LboxString LString;

	for( i = 0; i < ra.counter; i++ ) {
		Lview->AddRow();

		Lview->SetColumnPrintf( 0, "%d", i+1 );
		Ltoken.CreateToken( ra.array[i], "\t" );

		LString.operator = (Ltoken.Token[1]);
		LString.Replace( "From: ", "" );
		Lview->SetColumnText( 1, &LString );

		LString.operator = (Ltoken.Token[0]);
		LString.Replace( "Subject: ", "" );
		Lview->SetColumnText( 2, &LString );

		LString.operator = (Ltoken.Token[2]);
		LString.Replace( "Date: ", "" );
		Lview->SetColumnText( 3, &LString );
	}

	DllBFreeArray(&ra);

	Lview->Fit();
	return true;

}
  



  RcvData

  
// *********************************************************
// メールデータ受信
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::RcvData( LboxListview *Lview )
{
	if ( this->User.operator == ( "" ) ) {
		return false;
	}
	return LboxBasp::RcvData(
		this->User.szLboxString,
		this->Password.szLboxString,
		Lview
	);
}
BOOL LboxBasp::RcvData(
	LboxString *LUser, LboxString *LPass, LboxListview *Lview )
{
	return LboxBasp::RcvData(
		LUser->szLboxString,
		LPass->szLboxString,
		Lview
	);
}
BOOL LboxBasp::RcvData(
	LPTSTR lpUser, LPTSTR lpPass, LboxListview *Lview )
{
	this->ErrorDescription.SetChar(0,0);

	if ( this->lib == NULL ) {
		this->ErrorDescription.operator = (
			"Bsmtp.dll がインストールされていません"
		);
		return false;
	}

	LPFUNC_BPOP3 DllBPOP3;
	LPFUNC_BMIME DllBMIME;
	LPFUNC_BFreeArray DllBFreeArray;

	DllBPOP3 =
		(LPFUNC_BPOP3)GetProcAddress( lib, "BPOP3" );
	if ( DllBPOP3 == NULL ) {
		return false;
	}
	DllBMIME =
		(LPFUNC_BMIME)GetProcAddress( lib, "BMIME" );
	if ( DllBMIME == NULL ) {
		return false;
	}
	DllBFreeArray =
		(LPFUNC_BFreeArray)GetProcAddress( lib, "BFreeArray" );
	if ( DllBFreeArray == NULL ) {
		return false;
	}


	int nRet;
	RetArray ra,raRow;
	LboxString LString;

	LString.operator = (">");
	LString.operator += (this->RcvDir.szLboxString);

	this->ErrorDescription.SetChar( 0, 0 );
	nRet = DllBPOP3(
		this->POP3Server.szLboxString,
		lpUser,
		lpPass,
		"SAVEALL",
		LString.szLboxString,
		&ra,
		this->ErrorDescription.szLboxString
	);

	if ( nRet <= 0 ) {
		return false;
	}

	Lview->Initialize();
	Lview->AddColumn( LVCFMT_LEFT, 100, "" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "送信者" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "件名" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "受信日時" );
	Lview->AddColumn( LVCFMT_LEFT, 100, "ファイル" );

	int i,j;

	for( i = 0; i < ra.counter; i++ ) {
		nRet = DllBMIME(
			"GETNOF",
			ra.array[i],
			this->RcvDir.szLboxString,
			&raRow,
			this->ErrorDescription.szLboxString
		);
		if ( nRet <= 0 ) {
			continue;
		}
		Lview->AddRow();

		Lview->SetColumnPrintf( 0, "%d", i+1 );
		Lview->SetColumnText( 4, ra.array[i] );

		for( j = 0; j < raRow.counter; j++ ) {
			LString.operator = (raRow.array[j]);
			LString.SetChar( 5, 0 );
			if ( LString.operator == ("From:") ) {
				LString.operator = (raRow.array[j]);
				LString.Replace( "From: ", "" );
				Lview->SetColumnText( 1, &LString );
			}
		}

		for( j = 0; j < raRow.counter; j++ ) {
			LString.operator = (raRow.array[j]);
			LString.SetChar( 8, 0 );
			if ( LString.operator == ("Subject:") ) {
				LString.operator = (raRow.array[j]);
				LString.Replace( "Subject: ", "" );
				Lview->SetColumnText( 2, &LString );
			}
		}

		for( j = 0; j < raRow.counter; j++ ) {
			LString.operator = (raRow.array[j]);
			LString.SetChar( 5, 0 );
			if ( LString.operator == ("Date:") ) {
				LString.operator = (raRow.array[j]);
				LString.Replace( "Date: ", "" );
				Lview->SetColumnText( 3, &LString );
			}
		}
	}

	DllBFreeArray(&raRow);
	DllBFreeArray(&ra);

	Lview->Fit();
	return true;

}
  



  GetBody

  
// *********************************************************
// 本文読出し
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::GetBody(	
	LboxString *LFile, LboxString *LBody )
{
	return LboxBasp::GetBody(
		LFile->szLboxString,
		LBody
	);
}
BOOL LboxBasp::GetBody(	
	LPTSTR lpFile, LboxString *LBody )
{
	this->ErrorDescription.SetChar(0,0);

	if ( this->lib == NULL ) {
		this->ErrorDescription.operator = (
			"Bsmtp.dll がインストールされていません"
		);
		return false;
	}

	LPFUNC_BMIME DllBMIME;
	LPFUNC_BFreeArray DllBFreeArray;

	DllBMIME =
		(LPFUNC_BMIME)GetProcAddress( lib, "BMIME" );
	if ( DllBMIME == NULL ) {
		return false;
	}
	DllBFreeArray =
		(LPFUNC_BFreeArray)GetProcAddress( lib, "BFreeArray" );
	if ( DllBFreeArray == NULL ) {
		return false;
	}


	int nRet;
	RetArray ra;

	this->ErrorDescription.SetChar( 0, 0 );
	nRet = DllBMIME(
		"GETNOF",
		lpFile,
		this->RcvDir.szLboxString,
		&ra,
		this->ErrorDescription.szLboxString
	);
	if ( nRet <= 0 ) {
		return false;
	}

	int i;
	LboxString LString;

	LBody->SetChar( 0, 0 );
	for( i = 0; i < ra.counter; i++ ) {
		LString.operator = (ra.array[i]);
		LString.SetChar( 5, 0 );
		if ( LString.operator == ("Body:") ) {
			LString.operator = (ra.array[i]);
			LString.Replace( "Body: ", "" );
			if ( LBody->nLboxString
				< LString.nLboxString ) {
				LBody->Resize( LString.nLboxString );
			}
			LBody->operator = (&LString);
			break;
		}
	}

	DllBFreeArray(&ra);

	return true;

}
  



  DelMail

  
// *********************************************************
// メールデータ削除
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::DelMail( LboxString *LFile )
{
	if ( this->User.operator == ( "" ) ) {
		return false;
	}
	return LboxBasp::DelMail(
		this->User.szLboxString,
		this->Password.szLboxString,
		LFile->szLboxString
	);
}
BOOL LboxBasp::DelMail(
	LboxString *LUser, LboxString *LPass, LboxString *LFile )
{
	return LboxBasp::DelMail(
		LUser->szLboxString,
		LPass->szLboxString,
		LFile->szLboxString
	);
}
BOOL LboxBasp::DelMail(
	LPTSTR lpUser, LPTSTR lpPass, LPTSTR lpFile )
{
	this->ErrorDescription.SetChar(0,0);

	if ( this->lib == NULL ) {
		this->ErrorDescription.operator = (
			"Bsmtp.dll がインストールされていません"
		);
		return false;
	}

	LPFUNC_BPOP3 DllBPOP3;
	LPFUNC_BFreeArray DllBFreeArray;

	DllBPOP3 =
		(LPFUNC_BPOP3)GetProcAddress( lib, "BPOP3" );
	if ( DllBPOP3 == NULL ) {
		return false;
	}
	DllBFreeArray =
		(LPFUNC_BFreeArray)GetProcAddress( lib, "BFreeArray" );
	if ( DllBFreeArray == NULL ) {
		return false;
	}


	int nRet;
	RetArray ra;
	LboxString LString;

	LString.operator = (lpFile);
	LString.StripPath();
	LString.Insert( "DELU " );
	
	this->ErrorDescription.SetChar( 0, 0 );
	nRet = DllBPOP3(
		this->POP3Server.szLboxString,
		lpUser,
		lpPass,
		LString.szLboxString,
		this->RcvDir.szLboxString,
		&ra,
		this->ErrorDescription.szLboxString
	);

	DllBFreeArray(&ra);

	return true;

}
  



  ZenToHan

  
// *********************************************************
// 全角を半角に変換
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::ZenToHan( LboxString *LZen, LboxString *LHan )
{
	return ZenToHan(
		LZen->szLboxString,
		LHan
	);
}
BOOL LboxBasp::ZenToHan( LPTSTR lpZen, LboxString *LHan )
{
	return LboxBasp::StrConv(
		8,
		lpZen,
		LHan
	);
}
  



  HanToZen

  
// *********************************************************
// 半角を全角に変換
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::HanToZen( LboxString *LHan, LboxString *LZen )
{
	return HanToZen(
		LHan->szLboxString,
		LZen
	);
}
BOOL LboxBasp::HanToZen( LPTSTR lpHan, LboxString *LZen )
{
	return LboxBasp::StrConv(
		4,
		lpHan,
		LZen
	);
}
  



  StrConv

  
// *********************************************************
// 文字列変換
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::StrConv(
	long nType, LboxString *LBase, LboxString *LOut )
{
	return LboxBasp::StrConv(
		nType,
		LBase->szLboxString,
		LOut
	);
}
BOOL LboxBasp::StrConv(
	long nType, LPTSTR lpBase, LboxString *LOut )
{

	BOOL bRet;
	IBasp21Ptr pBasp;
	_bstr_t Base(lpBase);
	_bstr_t Ret("");

	bRet = true;
	int nErr = 0;

	pBasp	= NULL;
	try {
		TESTHR(pBasp.CreateInstance(__uuidof(Basp21)));
		nErr++;

		Ret.operator = (pBasp->StrConv( Base, nType ));
		nErr++;

		LOut->operator = ((LPTSTR)Ret);

		pBasp.Release();
		pBasp = NULL;
	}
	catch (_com_error &e)
	{
		if ( nErr >= 1 ) {
			pBasp.Release();
			pBasp = NULL;
		}
		bRet = false;
	}

	return bRet;
}
  



  HankanaToZen

  
// *********************************************************
// 文字列の中の半角カナを全角カナに変換
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxBasp::HankanaToZen( LboxString *LHan, LboxString *LZen )
{
	return HankanaToZen(
		LHan->szLboxString,
		LZen
	);
}
BOOL LboxBasp::HankanaToZen( LPTSTR lpHan, LboxString *LZen )
{

	BOOL bRet;
	IBasp21Ptr pBasp;
	_bstr_t Han(lpHan);
	_bstr_t Ret("");

	bRet = true;
	int nErr = 0;

	pBasp	= NULL;
	try {
		TESTHR(pBasp.CreateInstance(__uuidof(Basp21)));
		nErr++;

		Ret.operator = (pBasp->HAN2ZEN( Han ));
		nErr++;

		LZen->operator = ((LPTSTR)Ret);

		pBasp.Release();
		pBasp = NULL;
	}
	catch (_com_error &e)
	{
		if ( nErr >= 1 ) {
			pBasp.Release();
			pBasp = NULL;
		}
		bRet = false;
	}

	return bRet;
}
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ