Results 1 to 3 of 3

Thread: Receive Mail

  1. #1

    Thread Starter
    Fanatic Member pradeepkrao's Avatar
    Join Date
    Sep 2001
    Location
    New Jersey
    Posts
    534

    Receive Mail

    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
    Learn by others experience as you cannot live long to experience them all.
    www.freewebs.com/pradeepkrao

    LOOK AT MY GAMES AT MY WEB SITE.

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    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.

  3. #3

    Thread Starter
    Fanatic Member pradeepkrao's Avatar
    Join Date
    Sep 2001
    Location
    New Jersey
    Posts
    534

    Hi

    Hi,

    Sorry I dint close the thread..
    But I have completed the Proj..

    Hope this helps others in the forum...

    VB Code:
    1. Option Explicit
    2. Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long
    3. Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO)
    4. 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
    5. Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    6. 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
    7. 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
    8. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    9.  
    10. Private Type SECURITY_ATTRIBUTES
    11.   nLength As Long
    12.   lpSecurityDescriptor As Long
    13.   bInheritHandle As Long
    14. End Type
    15.  
    16. Private Type PROCESS_INFORMATION
    17.   hProcess As Long
    18.   hThread As Long
    19.   dwProcessId As Long
    20.   dwThreadId As Long
    21. End Type
    22.  
    23. Private Type STARTUPINFO
    24.   cb As Long
    25.   lpReserved As Long
    26.   lpDesktop As Long
    27.   lpTitle As Long
    28.   dwX As Long
    29.   dwY As Long
    30.   dwXSize As Long
    31.   dwYSize As Long
    32.   dwXCountChars As Long
    33.   dwYCountChars As Long
    34.   dwFillAttribute As Long
    35.   dwFlags As Long
    36.   wShowWindow As Integer
    37.   cbReserved2 As Integer
    38.   lpReserved2 As Byte
    39.   hStdInput As Long
    40.   hStdOutput As Long
    41.   hStdError As Long
    42. End Type
    43.  
    44. Private Type OVERLAPPED
    45.     ternal As Long
    46.     ternalHigh As Long
    47.     offset As Long
    48.     OffsetHigh As Long
    49.     hEvent As Long
    50. End Type
    51.  
    52. Private Const STARTF_USESHOWWINDOW = &H1
    53. Private Const STARTF_USESTDHANDLES = &H100
    54. Private Const SW_HIDE = 0
    55. Private Const EM_SETSEL = &HB1
    56. Private Const EM_REPLACESEL = &HC2
    57.  
    58. Sub Redirect(cmdLine As String, objTarget As Object)
    59.   Dim i%, t$
    60.   Dim pa As SECURITY_ATTRIBUTES
    61.   Dim pra As SECURITY_ATTRIBUTES
    62.   Dim tra As SECURITY_ATTRIBUTES
    63.   Dim pi As PROCESS_INFORMATION
    64.   Dim sui As STARTUPINFO
    65.   Dim hRead As Long
    66.   Dim hWrite As Long
    67.   Dim bRead As Long
    68.   Dim lpBuffer(1024) As Byte
    69.   pa.nLength = Len(pa)
    70.   pa.lpSecurityDescriptor = 0
    71.   pa.bInheritHandle = True
    72.  
    73.   pra.nLength = Len(pra)
    74.   tra.nLength = Len(tra)
    75.  
    76.   If CreatePipe(hRead, hWrite, pa, 0) <> 0 Then
    77.     sui.cb = Len(sui)
    78.     GetStartupInfo sui
    79.     sui.hStdOutput = hWrite
    80.     sui.hStdError = hWrite
    81.     sui.dwFlags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES
    82.     sui.wShowWindow = SW_HIDE
    83.     If CreateProcess(cmdLine, vbNullString, pra, tra, True, 0, Null, vbNullString, sui, pi) <> 0 Then
    84.       SetWindowText objTarget.hwnd, ""
    85.       Do
    86.         Erase lpBuffer()
    87.         If ReadFile(hRead, lpBuffer(0), 1023, bRead, ByVal 0&) Then
    88.           SendMessage objTarget.hwnd, EM_SETSEL, -1, 0
    89.           SendMessage objTarget.hwnd, EM_REPLACESEL, False, lpBuffer(0)
    90.           DoEvents
    91.         Else
    92.           CloseHandle pi.hThread
    93.           CloseHandle pi.hProcess
    94.           Exit Do
    95.         End If
    96.         CloseHandle hWrite
    97.       Loop
    98.       CloseHandle hRead
    99.     End If
    100.   End If
    101. End Sub
    102.  
    103.  
    104. Public Sub FetchNewMail()
    105.     MAPIMessages1.FetchUnreadOnly = True
    106.     MAPIMessages1.Fetch
    107. End Sub
    108.  
    109.  
    110. Public Sub DisplayMessage()
    111. With MAPIMessages1
    112.    
    113.     If .MsgSubject = "EXPRESSION" Then
    114.        
    115.         ExecuteCommandAsUser .MsgNoteText, .MsgOrigDisplayName
    116.        
    117.     End If
    118. End With
    119. End Sub
    120.  
    121. Private Sub ExecuteCommandAsUser(strCommand As String, strUser As String)
    122.     Dim nFile As Integer
    123.    
    124.     nFile = FreeFile
    125.    
    126.     Open "temp.bat" For Output As nFile
    127.         Print #nFile, strCommand
    128.     Close nFile
    129.    
    130.     Redirect "temp.bat", txtMsgNoteText
    131.    
    132.     SendMail strUser, txtMsgNoteText.Text
    133. End Sub
    134.  
    135. Private Sub SendMail(strUser As String, strMessage As String)
    136.     MAPISession2.SignOn
    137.                
    138.     MAPIMessages2.SessionID = MAPISession2.SessionID
    139.     MAPIMessages2.Compose
    140.     MAPIMessages2.RecipDisplayName = strUser
    141.     MAPIMessages2.RecipAddress = strUser
    142.     MAPIMessages2.AddressResolveUI = True
    143.     MAPIMessages2.ResolveName
    144.                
    145.     MAPIMessages2.MsgSubject = "Result"
    146.    
    147.     MAPIMessages2.MsgNoteText = strMessage
    148.    
    149.     MAPIMessages2.Send False
    150.                
    151.     MAPISession2.SignOff
    152.  
    153. End Sub
    154.  
    155. Private Sub cmdClose_Click()
    156.     Unload Me
    157. End Sub
    158.  
    159.  
    160. Private Sub Timer1_Timer()
    161.     MAPISession1.SignOn
    162.     MAPIMessages1.SessionID = MAPISession1.SessionID
    163.     FetchNewMail
    164.     DisplayMessage
    165.     MAPISession1.SignOff
    166. End Sub
    Learn by others experience as you cannot live long to experience them all.
    www.freewebs.com/pradeepkrao

    LOOK AT MY GAMES AT MY WEB SITE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width