MailClient.ChangeMailFlags Method


Changes the flags of an email on IMAP4 server.

[Visual Basic 6.0]
Public Sub ChangeMailFlags( _
    oInfo As MailInfo, _
    Flags As String _
)
[Visual C++]
public: HRESULT ChangeMailFlags(
    IMailInfo* oInfo,
    BSTR Flags
);

Parameters

oInfo
The MailInfo instance to change flags.
Flags
The flags of email, the value can be \Seen, \Deleted or (\Seen \Deleted)

Example

[Visual Basic 6.0, VBScript, Visual C++] The following example demonstrates how to mark \Seen and \Deleted flags to every email in "INBOX" with EAGetMail POP3 & IMAP ActiveX Object. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic 6.0]
Sub ChangeFlags(Server As String, _
User As String, _
Password As String, _
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 infos
    Set infos = oClient.GetMailInfoList()
    
    Dim i
    For i = 0 To infos.Count - 1
        Dim info
        Set info = infos.Item(i)

        oClient.ChangeMailFlags info, "\Seen \Deleted"
    Next
    
    oClient.Logout
    Exit Sub
ErrorHandle:
    MsgBox Err.Description
    
End Sub


[VBScript] Sub ChangeFlags(Server, _ User, _ Password, _ 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 infos Set infos = oClient.GetMailInfoList() Dim i For i = 0 To infos.Count - 1 Dim info Set info = infos.Item(i) oClient.ChangeMailFlags info, "\Seen \Deleted" Next oClient.Logout End Sub
[Visual C++] #include "stdafx.h" #include <windows.h> #include "eagetmailobj.tlh" using namespace EAGetMailObjLib; void ChangeFlags(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(__uuidof(EAGetMailObjLib::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(__uuidof(EAGetMailObjLib::MailClient)); oClient->LicenseCode = _T("TryIt"); oClient->Connect(oServer); IMailInfoCollectionPtr infos = oClient->GetMailInfoList(); for(long i = 0; i < infos->Count; i++) { IMailInfoPtr pInfo = infos->GetItem(i); oClient->ChangeMailFlags(pInfo, _T("\\Seen \\Deleted")); } oClient->Logout(); } catch(_com_error &ep) { _tprintf(_T("%s\r\n"), (TCHAR*)ep.Description()); } ::CoUninitialize(); }

See Also

MailClient.MarkAsRead Method
MailClient.Undelete Method