Public Function BRcvMail(pop3serer, uid$, pwd$, dlDir$) '------------------------------------------------------------ ' メールを受信 ' '------------------------------------------------------------ On Error GoTo BRcvMail_Err Dim W_POP3サーバ As Variant, W_ユーザ As Variant Dim W_メール位置 As Long Dim hwnd As Long, retIpPort As String Dim W_Socket番号 As Long, buf(16382) As Byte Dim W_文字列$ objLog.Debg "BRcvMail_Err START" hwnd = GetSystemMenu(Application.hWndAccessApp, 0) W_ユーザ = uid$ 'WinSockを開始 Call StartWinsock 'POP3サーバに接続 W_Socket番号 = ConnectSock(hwnd, pop3serer, "110", retIpPort) W_文字列 = getWStr(W_Socket番号) 'ユーザ W_文字列 = "USER " & W_ユーザ & vbCrLf Call SendData(W_Socket番号, W_文字列) W_文字列 = getWStr(W_Socket番号) 'パスワード W_文字列 = "PASS " & pwd$ & vbCrLf Call SendData(W_Socket番号, W_文字列) W_文字列 = getWStr(W_Socket番号) 'メールの件数を確認 W_文字列 = "STAT" & vbCrLf Call SendData(W_Socket番号, W_文字列) W_文字列 = getWStr(W_Socket番号) Dim W_メール件数 As Long: W_メール件数 = 0 Dim W_Ix1 As Long: W_Ix1 = 5 Do While W_Ix1 < W_文字長 And Mid(W_文字列, W_Ix1, 1) = " " W_Ix1 = W_Ix1 + 1 Loop Do While W_Ix1 < W_文字長 'メール件数を取り出し W_メール件数 = W_メール件数 * 10 + val(Mid(W_文字列, W_Ix1, 1)) W_Ix1 = W_Ix1 + 1 If Mid(W_文字列, W_Ix1, 1) = " " Then Exit Do End If Loop Debug.Print W_メール件数 'POP3サーバとの接続を終了 W_文字列 = "QUIT" & vbCrLf Call SendData(W_Socket番号, W_文字列) W_文字列 = getWStr(W_Socket番号) 'WinSockを終了 Call CloseWinsock(W_Socket番号) Call EndWinsock objLog.Debg "BRcvMail_Err END" ' Exit Function BRcvMail_Err: Dim erNum, erMsg$: erNum = err.Number: erMsg$ = "Send_mailEX:" & erNum & "," & err.Description objLog.Error erMsg$ err.Raise Number:=erNum, Description:=erMsg$ End Function