Hi,
How can I receive mail from VB, I need to parse the senders name and the subject of the message.
Any help is appreciated.
Thanks,
Pradeep
Printable View
Hi,
How can I receive mail from VB, I need to parse the senders name and the subject of the message.
Any help is appreciated.
Thanks,
Pradeep
Receive from where?
E-mail is sent to an e-mail server. The server saves the e-mail in a mailbox. A client comes along using a certain protocol to access the server. Depending on the server, will alter the protocols available. Depending on the implmentation of the server will depend on which protocols are best.
So: Which server? which protocol? which client? which access type and protocol?
Alternatively, search through the forum for Outlook integration or POP3 access.
Hi,
Sorry I dint close the thread..
But I have completed the Proj..
Hope this helps others in the forum...
VB Code:
Option Explicit Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO) Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Private Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Byte hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type OVERLAPPED ternal As Long ternalHigh As Long offset As Long OffsetHigh As Long hEvent As Long End Type Private Const STARTF_USESHOWWINDOW = &H1 Private Const STARTF_USESTDHANDLES = &H100 Private Const SW_HIDE = 0 Private Const EM_SETSEL = &HB1 Private Const EM_REPLACESEL = &HC2 Sub Redirect(cmdLine As String, objTarget As Object) Dim i%, t$ Dim pa As SECURITY_ATTRIBUTES Dim pra As SECURITY_ATTRIBUTES Dim tra As SECURITY_ATTRIBUTES Dim pi As PROCESS_INFORMATION Dim sui As STARTUPINFO Dim hRead As Long Dim hWrite As Long Dim bRead As Long Dim lpBuffer(1024) As Byte pa.nLength = Len(pa) pa.lpSecurityDescriptor = 0 pa.bInheritHandle = True pra.nLength = Len(pra) tra.nLength = Len(tra) If CreatePipe(hRead, hWrite, pa, 0) <> 0 Then sui.cb = Len(sui) GetStartupInfo sui sui.hStdOutput = hWrite sui.hStdError = hWrite sui.dwFlags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES sui.wShowWindow = SW_HIDE If CreateProcess(cmdLine, vbNullString, pra, tra, True, 0, Null, vbNullString, sui, pi) <> 0 Then SetWindowText objTarget.hwnd, "" Do Erase lpBuffer() If ReadFile(hRead, lpBuffer(0), 1023, bRead, ByVal 0&) Then SendMessage objTarget.hwnd, EM_SETSEL, -1, 0 SendMessage objTarget.hwnd, EM_REPLACESEL, False, lpBuffer(0) DoEvents Else CloseHandle pi.hThread CloseHandle pi.hProcess Exit Do End If CloseHandle hWrite Loop CloseHandle hRead End If End If End Sub Public Sub FetchNewMail() MAPIMessages1.FetchUnreadOnly = True MAPIMessages1.Fetch End Sub Public Sub DisplayMessage() With MAPIMessages1 If .MsgSubject = "EXPRESSION" Then ExecuteCommandAsUser .MsgNoteText, .MsgOrigDisplayName End If End With End Sub Private Sub ExecuteCommandAsUser(strCommand As String, strUser As String) Dim nFile As Integer nFile = FreeFile Open "temp.bat" For Output As nFile Print #nFile, strCommand Close nFile Redirect "temp.bat", txtMsgNoteText SendMail strUser, txtMsgNoteText.Text End Sub Private Sub SendMail(strUser As String, strMessage As String) MAPISession2.SignOn MAPIMessages2.SessionID = MAPISession2.SessionID MAPIMessages2.Compose MAPIMessages2.RecipDisplayName = strUser MAPIMessages2.RecipAddress = strUser MAPIMessages2.AddressResolveUI = True MAPIMessages2.ResolveName MAPIMessages2.MsgSubject = "Result" MAPIMessages2.MsgNoteText = strMessage MAPIMessages2.Send False MAPISession2.SignOff End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub Timer1_Timer() MAPISession1.SignOn MAPIMessages1.SessionID = MAPISession1.SessionID FetchNewMail DisplayMessage MAPISession1.SignOff End Sub