Unsubscribes an IMAP4 folder.
[Visual Basic 6.0]
Public Sub UnsubscribeFolder( _
folder As Imap4Folder _
)
[Visual C++]
public: HRESULT UnsubscribeFolder(
IImap4Folder* folder
);
Parameters
Remarks
Example
[Visual Basic 6.0, VBScript, Visual C++] The following example demonstrates how to create, subscribe, unsubscribe and delete "TestFolder" with EAGetMail POP3 & IMAP ActiveX Object. To get the full samples of EAGetMail, please refer to Samples section.
[Visual Basic 6.0]
Public Sub CreateFolder(ByVal Server As String, _
ByVal User As String, _
ByVal Password As String, _
ByVal SSLConnection As Boolean)
Const MailServerPop3 = 0
Const MailServerImap4 = 1
On Error GoTo ErrorHandle
Dim oServer As New EAGetMailObjLib.MailServer
oServer.Server = Server
oServer.User = User
oServer.Password = Password
oServer.SSLConnection = SSLConnection
oServer.Protocol = MailServerImap4
If oServer.SSLConnection = True Then
oServer.Port = 993
Else
oServer.Port = 143
End If
Dim oClient As New EAGetMailObjLib.MailClient
oClient.LicenseCode = "TryIt"
oClient.Connect oServer
Dim oFolder As EAGetMailObjLib.Imap4Folder
Set oFolder = oClient.CreateFolder(Nothing, "Test Folder")
If Not oFolder.Subscribed Then
oClient.SubscribeFolder oFolder
End If
Dim folders
folders = oClient.Imap4Folders
Dim i
For i = LBound(folders) To UBound(folders)
Dim fd As EAGetMailObjLib.Imap4Folder
Set fd = folders(i)
MsgBox "folder: " & fd.FullPath
Next
oClient.UnsubscribeFolder oFolder
oClient.DeleteFolder oFolder
oClient.Logout
Exit Sub
ErrorHandle:
MsgBox Err.Description
End Sub
[VBScript]
Sub CreateFolder(ByVal Server, _
ByVal User, _
ByVal Password, _
ByVal SSLConnection )
Const MailServerPop3 = 0
Const MailServerImap4 = 1
Dim oServer
Set oServer = CreateObject("EAGetMailObj.MailServer")
oServer.Server = Server
oServer.User = User
oServer.Password = Password
oServer.SSLConnection = SSLConnection
oServer.Protocol = MailServerImap4
If oServer.SSLConnection = True Then
oServer.Port = 993
Else
oServer.Port = 143
End If
Dim oClient
Set oClient = CreateObject("EAGetMailObj.MailClient")
oClient.LicenseCode = "TryIt"
oClient.Connect oServer
Dim oFolder
Set oFolder = oClient.CreateFolder(Nothing, "Test Folder")
If Not oFolder.Subscribed Then
oClient.SubscribeFolder oFolder
End If
Dim folders
folders = oClient.Imap4Folders
Dim i
For i = LBound(folders) To UBound(folders)
Dim fd
Set fd = folders(i)
MsgBox "folder: " & fd.FullPath
Next
oClient.UnsubscribeFolder oFolder
oClient.DeleteFolder oFolder
oClient.Logout
End Sub
[Visual C++]
#include "eagetmailobj.tlh"
using namespace EAGetMailObjLib;
void CreateFolder(LPCTSTR lpszServer,
LPCTSTR lpszUser,
LPCTSTR lpszPassword,
VARIANT_BOOL SSLConnection )
{
::CoInitialize( NULL );
const int MailServerPop3 = 0;
const int MailServerImap4 = 1;
try
{
IMailServerPtr oServer = NULL;
oServer.CreateInstance("EAGetMailObj.MailServer");
oServer->Server = lpszServer;
oServer->User = lpszUser;
oServer->Password = lpszPassword;
oServer->SSLConnection = SSLConnection;
oServer->Protocol = MailServerImap4;
if( SSLConnection == VARIANT_TRUE )
oServer->Port = 993;
else
oServer->Port = 143;
IMailClientPtr oClient = NULL;
oClient.CreateInstance("EAGetMailObj.MailClient");
oClient->LicenseCode = _T("TryIt");
oClient->Connect( oServer );
IImap4FolderPtr oFolder = oClient->CreateFolder( NULL, _T("Test Folder"));
if( oFolder->Subscribed == VARIANT_FALSE )
{
oClient->SubscribeFolder( oFolder );
}
_variant_t vtFolder = oClient->Imap4Folders ;
SAFEARRAY *psa = vtFolder.parray;
LONG UBound = 0, LBound = 0;
SafeArrayGetLBound( psa, 1, &LBound );
SafeArrayGetUBound( psa, 1, &UBound );
for( long i = LBound; i <= UBound; i++ )
{
_variant_t vt;
SafeArrayGetElement( psa, &i, &vt );
IImap4FolderPtr fd;
vt.pdispVal->QueryInterface( __uuidof(IImap4Folder), (void**)&fd);
_tprintf( _T("folder: %s\r\n"), (TCHAR*)fd->FullPath );
}
oClient->UnsubscribeFolder( oFolder );
oClient->DeleteFolder( oFolder );
oClient->Logout();
}
catch( _com_error &ep )
{
_tprintf( _T("%s\r\n"), (TCHAR*)ep.Description());
}
::CoUninitialize();
}