MailServer.SocksProxyServer Property


Gets or sets the socks4/5/http proxy server address (IP or internet domain name). For Exchange Web Service/WebDAV protocol, proxy server is not supported.

[Visual Basic 6.0]
Public Property Get SocksProxyServer() As String
Public Property Let SocksProxyServer( newVal As String)
[Visual C++]
public: get_SocksProxyServer(BSTR *pVal);
public: put_SocksProxyServer(BSTR newVal);

Property Value

A string value indicating the proxy server address (IP address or internet domain).

Remarks

If SocksProxyServer is not specified, the direct connection will be used; otherwise the proxy connection will be used. We don't suggest that you use the proxy server except it is your only choice.

Example

[Visual Basic 6.0, VBScript, Visual C++] The following example demonstrates how to receive email with EAGetMail POP3 & IMAP ActiveX Object, but it doesn't demonstrates the events and mail parsing usage. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic 6.0]
Public Sub ReceiveMail( _
ByVal sServer As String, _
ByVal sUserName As String, _
ByVal sPassword As String, _
ByVal bSSLConnection As Boolean)
    
    Const MailServerPop3 = 0
    Const MailServerImap4 = 1

    Const MailServerAuthLogin = 0
    Const MailServerAuthCRAM5 = 1
    Const MailServerAuthNTLM = 2
    
    Const ProxyType_Socks4 = 0
    Const ProxyType_Socks5 = 1
    Const ProxyType_Http = 2    
    
    'For evaluation usage, please use "TryIt" as the license code, otherwise the
    '"invalid license code" exception will be thrown. However, the object will expire in 1-2 months, then
    '"trial version expired" exception will be thrown.
    Dim oClient As New EAGetMailObjLib.MailClient
    oClient.LicenseCode = "TryIt"
    
    'To receive email from imap4 server, please change
    'MailServerPop3 to MailServerImap4 in MailServer constructor
    Dim oServer As New EAGetMailObjLib.MailServer
    oServer.Server = sServer
    oServer.User = sUserName
    oServer.Password = sPassword
    oServer.AuthType = MailServerAuthLogin
    oServer.SSLConnection = bSSLConnection
    oServer.Protocol = MailServerPop3
    
    oServer.SocksProxyServer = "192.168.0.1"
    oServer.SocksProxyPort = 1080
    ' if your proxy doesn't requires user authentication, please don't assign any value to 
    ' SocksProxyUser and SocksProxyPassword properties 
    oServer.SocksProxyUser = "tester"
    oServer.SocksProxyPassword = "pass"
    oServer.ProxyProtocol = ProxyType_Socks5     
    
    
    ''by default, the pop3 port is 110, imap4 port is 143,
    'the pop3 ssl port is 995, imap4 ssl port is 993
    'you can also change the port like this
    'oServer.Port = 110
    If oServer.Protocol = MailServerImap4 Then
        If oServer.SSLConnection Then
            oServer.Port = 993 'SSL IMAP4
        Else
            oServer.Port = 143 'IMAP4 normal
        End If
    Else
        If oServer.SSLConnection Then
            oServer.Port = 995 'SSL POP3
        Else
            oServer.Port = 110 'POP3 normal
        End If
    End If
    
On Error GoTo ErrorHandle
    oClient.Connect oServer

    Dim infos As EAGetMailObjLib.MailInfoCollection
    Set infos = oClient.GetMailInfoList()
    
    Dim i
    For i = 0 To infos.Count - 1
        Dim info As EAGetMailObjLib.MailInfo
        Set info = infos.Item(i)

        Dim oMail As EAGetMailObjLib.Mail
        Set oMail = oClient.GetMail(info)
        'Save mail to local
        oMail.SaveAs "d:\tempfolder\" & i & ".eml", True

        ' Delete email from server
        oClient.Delete info
    Next

    '' Delete method just mark the email as deleted,
    ' Quit method expunge the emails from server permanently.
    oClient.Quit
    Exit Sub

ErrorHandle:
    ''Error handle
    MsgBox Err.Description
    
    oClient.Close
End Sub


[VBScript] Sub ReceiveMail( _ ByVal sServer, _ ByVal sUserName, _ ByVal sPassword, _ ByVal bSSLConnection) Const MailServerPop3 = 0 Const MailServerImap4 = 1 Const MailServerAuthLogin = 0 Const MailServerAuthCRAM5 = 1 Const MailServerAuthNTLM = 2 Const ProxyType_Socks4 = 0 Const ProxyType_Socks5 = 1 Const ProxyType_Http = 2 'For evaluation usage, please use "TryIt" as the license code, otherwise the '"invalid license code" exception will be thrown. However, the object will expire in 1-2 months, then '"trial version expired" exception will be thrown. Dim oClient Set oClient = CreateObject("EAGetMailObj.MailClient") oClient.LicenseCode = "TryIt" 'To receive email from imap4 server, please change 'MailServerPop3 to MailServerImap4 in MailServer constructor Dim oServer Set oServer = CreateObject("EAGetMailObj.MailServer") oServer.Server = sServer oServer.User = sUserName oServer.Password = sPassword oServer.AuthType = MailServerAuthLogin oServer.SocksProxyServer = "192.168.0.1" oServer.SocksProxyPort = 1080 ' if your proxy doesn't requires user authentication, please don't assign any value to ' SocksProxyUser and SocksProxyPassword properties oServer.SocksProxyUser = "tester" oServer.SocksProxyPassword = "pass" oServer.ProxyProtocol = ProxyType_Socks5 oServer.SSLConnection = bSSLConnection oServer.Protocol = MailServerPop3 ''by default, the pop3 port is 110, imap4 port is 143, 'the pop3 ssl port is 995, imap4 ssl port is 993 'you can also change the port like this 'oServer.Port = 110 If oServer.Protocol = MailServerImap4 Then If oServer.SSLConnection Then oServer.Port = 993 'SSL IMAP4 Else oServer.Port = 143 'IMAP4 normal End If Else If oServer.SSLConnection Then oServer.Port = 995 'SSL POP3 Else oServer.Port = 110 'POP3 normal End If End If oClient.Connect oServer Dim infos Set infos = oClient.GetMailInfoList() Dim i For i = 0 To infos.Count - 1 Dim info Set info = infos.Item(i) Dim oMail Set oMail = oClient.GetMail(info) 'Save mail to local oMail.SaveAs "d:\tempfolder\" & i & ".eml", True ' Delete email from server oClient.Delete info Next '' Delete method just mark the email as deleted, ' Quit method expunge the emails from server permanently. oClient.Quit End Sub
[Visual C++] #include "stdafx.h" #include <windows.h> #include "eagetmailobj.tlh" using namespace EAGetMailObjLib; void ReceiveMail( LPCTSTR sServer, LPCTSTR sUserName, LPCTSTR sPassword, bool bSSLConnection) { ::CoInitialize(NULL); const int MailServerPop3 = 0; const int MailServerImap4 = 1; const int MailServerAuthLogin = 0; const int MailServerAuthCRAM5 = 1; const int MailServerAuthNTLM = 2; const int ProxyType_Socks4 = 0; const int ProxyType_Socks5 = 1; const int ProxyType_Http = 2; try { IMailClientPtr oClient; oClient.CreateInstance(__uuidof(EAGetMailObjLib::MailClient)); IMailServerPtr oServer; oServer.CreateInstance(__uuidof(EAGetMailObjLib::MailServer)); // For evaluation usage, please use "TryIt" as the license code, otherwise the // "invalid license code" exception will be thrown. However, the object will expire in 1-2 months, then // "trial version expired" exception will be thrown. oClient->LicenseCode = _T("TryIt"); oServer->Server = sServer; oServer->User = sUserName; oServer->Password = sPassword; oServer->AuthType = MailServerAuthLogin; oServer->SocksProxyServer = _T("192.168.0.1"); oServer->SocksProxyPort = 1080; // if your proxy doesn't requires user authentication, please don't assign any value to // SocksProxyUser and SocksProxyPassword properties oServer->SocksProxyUser = _T("tester"); oServer->SocksProxyPassword = _T("pass"); oServer->ProxyProtocol = ProxyType_Socks5; INT nProtocol = MailServerPop3; oServer->Protocol = nProtocol; if(nProtocol == MailServerPop3) { if(bSSLConnection) { oServer->Port = 995; oServer->SSLConnection = VARIANT_TRUE; } else { oServer->Port = 110; } } else { if(bSSLConnection) { oServer->Port = 993; oServer->SSLConnection = VARIANT_TRUE; } else { oServer->Port = 143; } } oClient->Connect(oServer); IMailInfoCollectionPtr infos = oClient->GetMailInfoList(); for(long i = 0; i < infos->Count; i++) { IMailInfoPtr pInfo = infos->GetItem(i); IMailPtr oMail = oClient->GetMail(pInfo); TCHAR szFile[MAX_PATH+1]; memset(szFile, 0, sizeof(szFile)); ::wsprintf(szFile, _T("d:\\tempfolder\\%d.eml"), i); //save to local disk oMail->SaveAs(szFile, VARIANT_TRUE); // delete email from server oClient->Delete(pInfo); } // Delete method just mark the email as deleted, // Quit method expunge the emails from server permanently. oClient->Quit(); } catch(_com_error &ep) { _tprintf(_T("ERROR: %s\r\n"), (TCHAR*)ep.Description()); } ::CoUninitialize(); }

See Also

User Authentication and SSL/TLS Connection
MailClient.Connect Method

Online Tutorials

Read Email and Parse Email in VB6 - Tutorial
Read Email and Parse Email in Delphi - Tutorial
Read Email and Parse Email VC++ - Tutorial